Repository navigation
fix(diag): skip a diag, stub-fallback or spool line nested past the limit - #29059
Conversation
…imit The diag snapshot query, the stub-fallback counter and the inbound spool reader parse each JSONL line inside except ValueError (the counter only JSONDecodeError). json.loads raises RecursionError on a line nested past the interpreter limit, which is neither, so one such line raised out of the whole read; the counter promises it never raises. Each now catches ValueError and RecursionError and skips the line.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS This is a narrow, proportionate fix at the right place: each reader now catches [DESIGN-REVIEWED] 41e6e53 Description read[DESCRIPTION-READ] e5364d53ed02bf8dc50970460a57768da3d447f52844a5e18e5a37fd1e5350d6 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (4 items) — 4 justifiedIntent: a single diag, stub-fallback or inbound-spool line nested too deeply should cost only that line, not the whole read. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 41e6e53 Description read[DESCRIPTION-READ] a00198c03e544f8987a4694b31fb55e8bb9311ed4d8b9923fd9597850fd71472 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (4 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: diag, stub-fallback and spool readers skip a JSON line nested past the recursion limit.
Problem / Motivation
Goal: One diag snapshot, stub-fallback or inbound-spool line nested past the recursion limit costs that line, not the whole read.
The diag snapshot query (
Recorder._iter_rows), the stub-fallback counter (fallback_counts) and the inbound spool reader (_read_entries) parse each JSONL line insideexcept ValueError(the counter,except json.JSONDecodeError).json.loadsraisesRecursionErroron a line nested past the interpreter limit, which is neither, so one such line raised out of the read. The counter documents that it never raises.Why it matters
The diag query answers the health questions an operator asks after an incident, the counter feeds the gateway fallback-rate stats, and the spool reader runs on the boot path to replay inbound messages. Each already skips a torn line so one bad record cannot stop it; a deeply nested line stopped it instead.
Not a goal
What changed (motivation → approach → change)
Symptom: one
[[[[...]]]]line past the decoder depth makes the reader raise. Cause:RecursionErroris not aValueError. Change: each of the three sites catches(ValueError, RecursionError)and skips the line, the shape the repo readers that already handle it use (for exampleapps/builtins/issue_radar/backend/pipeline_fold.py), and the history readers in #29020.Recorder._iter_rowsdiag/recorder.pyfallback_countsmcp_gateway/stub_fallback.py_read_entriesmessaging/inbound_spool.pyBackwards compatibility
Compatible: every line that parsed before parses the same; only a line that raised is now skipped.
Removes nothing: no record, route or setting is removed.
Tests
test/test_infra_readers_nested_line.pywrites a nested line beside one ordinary record for each reader and asserts the reader does not raise and still returns the ordinary record. All three fail on main.Proof: PROVEN test/test_infra_readers_nested_line.py::test_the_diag_query_skips_a_nested_line, test/test_infra_readers_nested_line.py::test_the_stub_fallback_counter_skips_a_nested_line, test/test_infra_readers_nested_line.py::test_the_inbound_spool_skips_a_nested_line (head 41e6e53)
Manual verification
N/A. Each test drives the real reader against a temp file.
Related Issues
Part of #29018 (these three readers; the dashboard readers are in #29058).
Sibling sweep
Swept: git grep -nA2 "json.loads(" -- src/kiro_crew/diag/recorder.py src/kiro_crew/mcp_gateway/stub_fallback.py src/kiro_crew/messaging/inbound_spool.py
Sibling: src/kiro_crew/diag/recorder.py -- changed here
Sibling: src/kiro_crew/mcp_gateway/stub_fallback.py -- changed here
Sibling: src/kiro_crew/messaging/inbound_spool.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/usage_spend.py -- tracked in #29058
Pattern harvest
Rule candidate: semgrep
Pattern: json.loads(...) inside except ValueError (or JSONDecodeError) with no RecursionError, in a line reader that promises to skip bad lines
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the Apache-2.0 license of this project.