Skip to content

fix: surface analysis parse failures instead of silently swallowing them#58

Merged
Treelovah merged 1 commit intomainfrom
fix/analyzer-parse-failure-handling
Feb 27, 2026
Merged

fix: surface analysis parse failures instead of silently swallowing them#58
Treelovah merged 1 commit intomainfrom
fix/analyzer-parse-failure-handling

Conversation

@Treelovah
Copy link
Contributor

When the analyzer LLM returns truncated or malformed JSON, parseAnalysisResponse was catching the SyntaxError, logging to stderr, and returning a zeroed-out AnalysisResult. All three callers — interactive run-flow, CLI run command, and analyze command — then unconditionally printed "Analysis complete" with a green checkmark. The user sees all-zero scores and has no idea the analysis actually failed.

This adds a parseFailed flag to AnalysisResult. When the JSON parse fails, the flag is set. All three callers now check it and show a yellow warning with retry instructions instead of a green success message.

Observed in the wild: Gemini 3 Pro on substring-bypass hit its output token limit, truncating the JSON response at position 3526.

Closes #56

@Treelovah Treelovah requested a review from pi3-code February 26, 2026 22:19
@Treelovah Treelovah force-pushed the fix/analyzer-parse-failure-handling branch from 0c2b231 to 3123565 Compare February 27, 2026 00:02
When the analyzer LLM returns truncated JSON, parseAnalysisResponse
was catching the error, printing to stderr where nobody reads it, and
returning a zeroed-out result. Every caller then printed "Analysis
complete" with a green checkmark. And then every load site that read
the result back from disk would render all-zero scores as if the model
genuinely scored zero on everything.

Added a parseFailed flag to AnalysisResult so callers can distinguish
"the model scored you low" from "we couldn't even read the response."
All three analysis call sites now show a warning with retry instructions.

Added a shared loadAnalysisResult helper that returns null for
parseFailed results — all five disk load sites (results list, compare,
challenge view, report, interactive browser) now use it instead of
inline JSON.parse. Failed analyses show as "-" in tables and are
excluded from reports, same as if no analysis was run.

Closes #56
@Treelovah Treelovah force-pushed the fix/analyzer-parse-failure-handling branch from 3123565 to 1fdeac2 Compare February 27, 2026 00:19
@Treelovah Treelovah merged commit e5779f0 into main Feb 27, 2026
3 checks passed
@Treelovah Treelovah deleted the fix/analyzer-parse-failure-handling branch February 27, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analyzer silently swallows JSON parse failures, shows misleading 'Analysis complete'

1 participant