Skip to content

fix: narrow JSON parse exception in analyze_bi.py#116

Open
andrewwhitecdw wants to merge 1 commit into
Agent-Field:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/analyze-bi-json-except
Open

fix: narrow JSON parse exception in analyze_bi.py#116
andrewwhitecdw wants to merge 1 commit into
Agent-Field:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/analyze-bi-json-except

Conversation

@andrewwhitecdw

Copy link
Copy Markdown
Contributor

Bug

analyze_bi.py used a bare except: while parsing JSONL lines, which could mask KeyboardInterrupt and hide malformed input.

Fix

Catch json.JSONDecodeError explicitly.

Test

Added tests/test_diagrams_analyze_bi.py with a regression test that loads the script, feeds it a JSONL file containing an invalid line, and asserts valid lines are still parsed.

Verification

AGENTFIELD_SERVER=http://localhost:9999 pytest tests/test_diagrams_analyze_bi.py -v passes (1 test).

analyze_bi.py used a bare  while parsing JSONL lines, which
could mask KeyboardInterrupt and hide malformed input. Catch
json.JSONDecodeError explicitly instead.

Adds a regression test that loads the script, feeds it a JSONL file with
one invalid line, and asserts valid lines are still parsed.

Signed-off-by: Andrew White <andrewh@cdw.com>
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.

1 participant