Merge pull request #3774 from mastertyko/fix/3759-preferences-section-warn-once
fix(gsd): suppress repeated preferences section warnings
This commit is contained in:
commit
695cab8b63
2 changed files with 26 additions and 1 deletions
|
|
@ -200,11 +200,13 @@ function loadPreferencesFile(path: string, scope: "global" | "project"): LoadedG
|
|||
}
|
||||
|
||||
let _warnedUnrecognizedFormat = false;
|
||||
let _warnedSectionParse = false;
|
||||
|
||||
/** @internal Reset the warn-once flags — exported for testing only. */
|
||||
export function _resetParseWarningFlag(): void {
|
||||
_warnedUnrecognizedFormat = false;
|
||||
_warnedFrontmatterParse = false;
|
||||
_warnedSectionParse = false;
|
||||
}
|
||||
|
||||
/** @internal Exported for testing only */
|
||||
|
|
@ -309,7 +311,10 @@ function parseHeadingListFormat(content: string): GSDPreferences {
|
|||
|
||||
typed[targetSection] = value;
|
||||
} catch (e) {
|
||||
logWarning("guided", `preferences section parse failed: ${(e as Error).message}`);
|
||||
if (!_warnedSectionParse) {
|
||||
_warnedSectionParse = true;
|
||||
logWarning("guided", `preferences section parse failed: ${(e as Error).message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
parsePreferencesMarkdown,
|
||||
_resetParseWarningFlag,
|
||||
} from "../preferences.ts";
|
||||
import { _resetLogs, peekLogs } from "../workflow-logger.ts";
|
||||
import type { GSDPreferences, GSDModelConfigV2, GSDPhaseModelConfig } from "../preferences.ts";
|
||||
|
||||
// ── Git preferences ──────────────────────────────────────────────────────────
|
||||
|
|
@ -422,6 +423,25 @@ test("parsePreferencesMarkdown parses heading+list format without frontmatter (#
|
|||
assert.deepStrictEqual(result!.git, { isolation: "none" });
|
||||
});
|
||||
|
||||
test("section parse warning is emitted at most once for heading+list YAML failures (#3759)", () => {
|
||||
_resetParseWarningFlag();
|
||||
_resetLogs();
|
||||
|
||||
const content = `## Git
|
||||
bad: [
|
||||
`;
|
||||
|
||||
parsePreferencesMarkdown(content);
|
||||
parsePreferencesMarkdown(content);
|
||||
parsePreferencesMarkdown(content);
|
||||
|
||||
const warnings = peekLogs().filter((entry) => entry.component === "guided" && entry.message.includes("preferences section parse failed"));
|
||||
assert.equal(warnings.length, 1, `expected exactly 1 guided warning, got ${warnings.length}`);
|
||||
|
||||
_resetParseWarningFlag();
|
||||
_resetLogs();
|
||||
});
|
||||
|
||||
// ── Experimental preferences ─────────────────────────────────────────────────
|
||||
|
||||
test("experimental.rtk: true is accepted and stored", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue