rehearsal-report parse_diagnosis wrongly parses an EMPTY diagnosis as a valid object under jq 1.6 — the transient 5xx retry never fires #140

Closed
opened 2026-09-11 23:09:45 +00:00 by matou-build-agent · 2 comments

Surfaced while fixing #139 (test prompt-path location-independence).

parse_diagnosis() in rehearsal-report.sh decides whether a headless
diagnosis is a usable JSON object via jq -e 'type=="object"' <<<"$s". When
the diagnosis is EMPTY (claude exited non-zero, e.g. a 529 transient — stdout
captured is ""), the behaviour of jq -e on empty input is version-dependent:

  • jq >= 1.7: no input value -> -e exits non-zero -> parse_diagnosis ""
    correctly returns 1 (fails), so the reporter's transient-retry branch
    (! parse_diagnosis "$diagnosis" && claude_transient_hit ...) fires.
  • jq 1.6: jq -e 'type=="object"' on empty input exits 0 -> the if
    branch printf '%s' "$s"; return 0 runs -> parse_diagnosis "" wrongly
    returns SUCCESS. ! parse_diagnosis is then false, short-circuits the
    transient check, and the loop breaks after ONE claude call. The reporter
    never retries the 5xx/overloaded fault and files the generic fallback with
    an empty body.

Repro (jq 1.6): printf '' | jq -e 'type=="object"'; echo $? -> 0.

Impact: on any host/CI with jq < 1.7, tests/rehearsal-report-test.sh (14a)
and tests/rehearsal-healer-test.sh fail on
the reporter did not retry the transient / the transient retry was not announced, and — more importantly at runtime — a real 529 brownout during a
rehearsal diagnosis is filed as an unparseable generic fallback instead of
being retried once. dev-factory CI is green today because it runs jq >= 1.7;
a swarm worker on a jq-1.6 box hits it (observed 2026-09-11).

Proposed fix: make parse_diagnosis robust to empty/blank input
independent of jq version — e.g. [ -n "${s//[[:space:]]/}" ] || return 1
before the first jq -e, and/or guard the jq -e result on non-empty input.
Add a parse_diagnosis "" -> non-zero assertion to the rehearsal test so the
regression is pinned offline.

Out of scope of #139: #139 fixed only the tests' *_PROMPT_FILE
overrides (path resolution); this is a separate product-code robustness bug in
rehearsal-report.sh and is not fixed there.

Surfaced while fixing #139 (test prompt-path location-independence). `parse_diagnosis()` in `rehearsal-report.sh` decides whether a headless diagnosis is a usable JSON object via `jq -e 'type=="object"' <<<"$s"`. When the diagnosis is EMPTY (claude exited non-zero, e.g. a 529 transient — stdout captured is ""), the behaviour of `jq -e` on empty input is version-dependent: - jq >= 1.7: no input value -> `-e` exits non-zero -> `parse_diagnosis ""` correctly returns 1 (fails), so the reporter's transient-retry branch (`! parse_diagnosis "$diagnosis" && claude_transient_hit ...`) fires. - jq 1.6: `jq -e 'type=="object"'` on empty input exits **0** -> the `if` branch `printf '%s' "$s"; return 0` runs -> `parse_diagnosis ""` wrongly returns SUCCESS. `! parse_diagnosis` is then false, short-circuits the transient check, and the loop `break`s after ONE claude call. The reporter never retries the 5xx/overloaded fault and files the generic fallback with an empty body. Repro (jq 1.6): `printf '' | jq -e 'type=="object"'; echo $?` -> `0`. Impact: on any host/CI with jq < 1.7, `tests/rehearsal-report-test.sh` (14a) and `tests/rehearsal-healer-test.sh` fail on `the reporter did not retry the transient` / `the transient retry was not announced`, and — more importantly at runtime — a real 529 brownout during a rehearsal diagnosis is filed as an unparseable generic fallback instead of being retried once. dev-factory CI is green today because it runs jq >= 1.7; a swarm worker on a jq-1.6 box hits it (observed 2026-09-11). **Proposed fix:** make `parse_diagnosis` robust to empty/blank input independent of jq version — e.g. `[ -n "${s//[[:space:]]/}" ] || return 1` before the first `jq -e`, and/or guard the `jq -e` result on non-empty input. Add a `parse_diagnosis ""` -> non-zero assertion to the rehearsal test so the regression is pinned offline. **Out of scope of #139:** #139 fixed only the tests' `*_PROMPT_FILE` overrides (path resolution); this is a separate product-code robustness bug in `rehearsal-report.sh` and is not fixed there.
Author
Member

swarm-claim host=bens-mac-04 run=8596
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=8596 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #140 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 140,
  "status": "success",
  "commits": [
    "50044cd"
  ],
  "changed_files": [
    "rehearsal-report.sh",
    "tests/rehearsal-report-test.sh",
    "docs/GOTCHAS.md"
  ],
  "tests": [
    {
      "command": "bash tests/rehearsal-report-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "parse_diagnosis robust to empty/blank input independent of jq version": "rehearsal-report.sh: `[ -n \"${s//[[:space:]]/}\" ] || return 1` guards before the first `jq -e`; jq 1.6 on this box no longer reads empty as an object (commit 50044cd)",
    "a parse_diagnosis \"\" -> non-zero assertion pins the regression offline": "tests/rehearsal-report-test.sh case 14a-unit extracts the real parse_diagnosis and asserts empty/blank/fence-only -> non-zero and a clean object still accepted; without the guard case 14a reds on jq 1.6 (verified)"
  },
  "summary": "parse_diagnosis rejects empty/blank input before jq -e so a 529 brownout retries on jq 1.6, with an offline regression test and GOTCHAS 52.",
  "blockers": []
}
**close-report** for #140 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 140, "status": "success", "commits": [ "50044cd" ], "changed_files": [ "rehearsal-report.sh", "tests/rehearsal-report-test.sh", "docs/GOTCHAS.md" ], "tests": [ { "command": "bash tests/rehearsal-report-test.sh", "exit_code": 0 } ], "criteria": { "parse_diagnosis robust to empty/blank input independent of jq version": "rehearsal-report.sh: `[ -n \"${s//[[:space:]]/}\" ] || return 1` guards before the first `jq -e`; jq 1.6 on this box no longer reads empty as an object (commit 50044cd)", "a parse_diagnosis \"\" -> non-zero assertion pins the regression offline": "tests/rehearsal-report-test.sh case 14a-unit extracts the real parse_diagnosis and asserts empty/blank/fence-only -> non-zero and a clean object still accepted; without the guard case 14a reds on jq 1.6 (verified)" }, "summary": "parse_diagnosis rejects empty/blank input before jq -e so a 529 brownout retries on jq 1.6, with an offline regression test and GOTCHAS 52.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#140
No description provided.