{"record":{"id":"3194824ce70f7f1a","repo":"can1357/oh-my-pi","slug":"settings-config-is-invalid-filepath-result-ba","errorCode":null,"errorMessage":"Settings config is invalid: ${filePath}${result.backupPath ? ` (moved to ${result.backupPath})` : \"\"}: ${String(result.error)}","messagePattern":"Settings config is invalid: (.+?)(.+?)\\)` : \"\"\\}: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/config/settings.ts","lineNumber":1492,"sourceCode":"\t\t\t\t`Settings config is invalid and could not be moved aside: ${filePath}; refusing to overwrite it: ${String(error)}`,\n\t\t\t);\n\t\t}\n\t\tlogger.warn(\"Settings: moved invalid config aside\", {\n\t\t\tpath: filePath,\n\t\t\tbackupPath,\n\t\t\terror: String(result.error),\n\t\t});\n\t\treturn { ...result, backupPath };\n\t}\n\n\t#unwrapYamlLoadResult(filePath: string, result: YamlLoadResult): RawSettings | null {\n\t\tswitch (result.kind) {\n\t\t\tcase \"missing\":\n\t\t\t\treturn null;\n\t\t\tcase \"loaded\":\n\t\t\t\treturn result.settings;\n\t\t\tcase \"invalid\":\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Settings config is invalid: ${filePath}${result.backupPath ? ` (moved to ${result.backupPath})` : \"\"}: ${String(result.error)}`,\n\t\t\t\t);\n\t\t\tcase \"unreadable\":\n\t\t\t\tthrow new Error(`Failed to read settings config ${filePath}: ${String(result.error)}`);\n\t\t}\n\t}\n\n\tasync #readExistingMainYaml(quarantineInvalid: boolean): Promise<MainYamlReadResult> {\n\t\tif (!this.#configPath) return { settings: null, configPath: null };\n\t\tfor (const filename of MAIN_CONFIG_FILENAMES) {\n\t\t\tconst configPath = path.join(this.#agentDir, filename);\n\t\t\tconst loaded = quarantineInvalid\n\t\t\t\t? await this.#loadYamlIfPresentForStartup(configPath)\n\t\t\t\t: this.#unwrapYamlLoadResult(configPath, await this.#loadYamlIfPresent(configPath, false));\n\t\t\tif (loaded) return { settings: loaded, configPath };\n\t\t}\n\t\treturn {\n\t\t\tsettings: null,","sourceCodeStart":1474,"sourceCodeEnd":1510,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/config/settings.ts#L1474-L1510","documentation":"Thrown when the settings YAML loads with kind === \"invalid\": the file exists and is readable but fails parsing/schema validation. Before throwing, the loader quarantines the broken file by renaming it to <path>.broken-<timestamp>-<pid>-<uuid> and reports the backup location plus the parse error. Settings are strict — an invalid file is never silently ignored for the main config.","triggerScenarios":"Reading settings.yaml that contains malformed YAML (bad indentation, tabs, unbalanced quotes) or content failing the settings schema (wrong types for known keys).","commonSituations":"Hand-editing YAML and breaking indentation; pasting JSON5/JSON into a file that needs stricter YAML; a newer/older version changed the schema; merge-conflict markers left in the file.","solutions":["Read the embedded parse error and fix the YAML at the indicated line","Recover content from the .broken-* backup the loader created next to the file, fix it, and replace the file","Validate the YAML with a linter before saving","If the schema changed after an upgrade, migrate keys per the changelog"],"exampleFix":"// before (settings.yaml)\nsettings:\n\ttheme: dark\n// after (tabs are invalid YAML indentation)\nsettings:\n  theme: dark","handlingStrategy":"try-catch","validationCode":"async function yamlParses(path) {\n  try { Bun.YAML.parse(await Bun.file(path).text()); return true; } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { const s = await loadSettings(); } catch (e) {\n  if (String(e).startsWith('Settings config is invalid')) {\n    // recover from the .broken-* backup named in the message, fix, retry\n    const m = String(e).match(/moved to ([^)]+)\\)/);\n    logger.error('Settings YAML invalid; backup at', { backup: m?.[1] });\n  } else throw e;\n}","preventionTips":["Lint settings.yaml with a YAML parser before saving","Use spaces, never tabs, for YAML indentation","After version upgrades, check the changelog for settings schema changes"],"tags":["settings","yaml","validation"],"backgroundTag":"invalid-yaml-config","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}