{"record":{"id":"c6b9402c5116e923","repo":"earendil-works/pi","slug":"failed-to-parse-theme-label-error","errorCode":null,"errorMessage":"Failed to parse theme ${label}: ${error}","messagePattern":"Failed to parse theme (.+?): (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/interactive/theme/theme.ts","lineNumber":602,"sourceCode":"\t\t}\n\t\tif (otherErrors.length > 0) {\n\t\t\terrorMessage += `\\n\\nOther errors:\\n${otherErrors.join(\"\\n\")}`;\n\t\t}\n\n\t\tthrow new Error(errorMessage);\n\t}\n\n\tconst themeJson = json as ThemeJson;\n\tassertThemeNameIsValid(themeJson.name);\n\treturn themeJson;\n}\n\nfunction parseThemeJsonContent(label: string, content: string): ThemeJson {\n\tlet json: unknown;\n\ttry {\n\t\tjson = JSON.parse(stripBom(content));\n\t} catch (error) {\n\t\tthrow new Error(`Failed to parse theme ${label}: ${error}`);\n\t}\n\treturn parseThemeJson(label, json);\n}\n\nfunction loadThemeJson(name: string): ThemeJson {\n\tconst builtinThemes = getBuiltinThemes();\n\tif (name in builtinThemes) {\n\t\treturn builtinThemes[name];\n\t}\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme?.sourcePath) {\n\t\tconst content = fs.readFileSync(registeredTheme.sourcePath, \"utf-8\");\n\t\treturn parseThemeJsonContent(registeredTheme.sourcePath, content);\n\t}\n\tif (registeredTheme) {\n\t\tthrow new Error(`Theme \"${name}\" does not have a source path for export`);\n\t}\n\tconst customThemesDir = getCustomThemesDir();","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/modes/interactive/theme/theme.ts#L584-L620","documentation":"Thrown by parseThemeJsonContent when the theme file's content is not valid JSON (JSON.parse throws); the underlying parse error is appended. This is the catch branch of a try/catch around JSON.parse after BOM stripping.","triggerScenarios":"Thrown at packages/coding-agent/src/modes/interactive/theme/theme.ts:602 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the JSON syntax error described in the appended message (e.g. trailing commas, unquoted keys, stray characters)","Validate the file with a JSON linter before reloading the theme","Ensure the file was not truncated or saved with non-UTF8 encoding"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}