permission-request order mails nothing on jq 1.6 when its state file is missing or empty #70

Merged
city-root merged 1 commit from worker/gascitypacks-iq1 into main 2026-11-12 16:56:14 +00:00
Contributor

Fixes gascitypacks-iq1: the permission-request order mailed nothing on jq 1.6 when its state file was missing or empty.

Cause. The order checked its state with jq -e 'type == "object"'. On jq 1.6 that prints nothing and exits 0 on empty input (1.7 and later exit 1), so the fallback to {} never ran. With the state empty, jq -e 'has($k)' also printed nothing and exited 0, every request counted as already mailed, and the empty state was written back. This is the failure of tests/permission-request.sh on the CI runner in #49.

Change.

  • roles/assets/scripts/permission-request.sh validates the state slurped: jq -es 'length == 1 and (.[0] | type == "object")'. No input, or only blanks, is [] and fails on every jq version, so the state falls back to {}. One changed line and a comment; no new shell logic.
  • tests/permission-request.sh no longer seeds the state file (that was the workaround). It runs the order on a state file that is missing, empty, blank, an array, and an object holding another request. Each case must mail the Worker's request once and nothing on a second run. fail still prints jq --version.
  • .changelog/permission-request-jq16.md: a Fixed fragment.

Checked.

  • tests/permission-request.sh passes on jq 1.6, 1.7.1 and 1.8.2.
  • The old script fails it on 1.6 (missing: want one mail) and passes on 1.7.1, so the test catches the bug.
  • shellcheck and the changelog v2 checker are clean.

The live order. The Mac's supervisor has /opt/homebrew/bin ahead of /usr/bin on its PATH, so it runs Homebrew's jq 1.8.2, not 1.6. The live order has been mailing: its state file holds the two requests mailed at 13:27 and 13:43 CET (12:27Z and 12:43Z), the two mails the Operator received. Only the forge runner has jq 1.6, which is where the bug showed.

Bead: gascitypacks-iq1

Fixes `gascitypacks-iq1`: the `permission-request` order mailed nothing on jq 1.6 when its state file was missing or empty. **Cause.** The order checked its state with `jq -e 'type == "object"'`. On jq 1.6 that prints nothing and exits 0 on empty input (1.7 and later exit 1), so the fallback to `{}` never ran. With the state empty, `jq -e 'has($k)'` also printed nothing and exited 0, every request counted as already mailed, and the empty state was written back. This is the failure of `tests/permission-request.sh` on the CI runner in #49. **Change.** - `roles/assets/scripts/permission-request.sh` validates the state slurped: `jq -es 'length == 1 and (.[0] | type == "object")'`. No input, or only blanks, is `[]` and fails on every jq version, so the state falls back to `{}`. One changed line and a comment; no new shell logic. - `tests/permission-request.sh` no longer seeds the state file (that was the workaround). It runs the order on a state file that is missing, empty, blank, an array, and an object holding another request. Each case must mail the Worker's request once and nothing on a second run. `fail` still prints `jq --version`. - `.changelog/permission-request-jq16.md`: a `Fixed` fragment. **Checked.** - `tests/permission-request.sh` passes on jq 1.6, 1.7.1 and 1.8.2. - The old script fails it on 1.6 (`missing: want one mail`) and passes on 1.7.1, so the test catches the bug. - `shellcheck` and the changelog v2 checker are clean. **The live order.** The Mac's supervisor has `/opt/homebrew/bin` ahead of `/usr/bin` on its PATH, so it runs Homebrew's jq 1.8.2, not 1.6. The live order has been mailing: its state file holds the two requests mailed at 13:27 and 13:43 CET (12:27Z and 12:43Z), the two mails the Operator received. Only the forge runner has jq 1.6, which is where the bug showed. Bead: gascitypacks-iq1
fix: permission-request order mails on jq 1.6 with its state file missing or empty (gascitypacks-iq1)
All checks were successful
test / changelog (pull_request) Successful in 5s
test / lint (pull_request) Successful in 21s
test / scripts (pull_request) Successful in 35s
b11c866300
On jq 1.6 (the forge runner's) `jq -e 'type == "object"'` on empty input
prints nothing and exits 0, where 1.7 and later exit 1. With no state file the
order's state was empty, the fallback to '{}' never ran, every `has($k)` on the
empty state printed nothing and exited 0, so every request counted as already
mailed and the empty state was written back. The order read its state through
that check on a host with jq 1.6 and mailed nothing.

The state is now validated slurped, `jq -es 'length == 1 and (.[0] | type ==
"object")'`: no input, or only blanks, is [] and fails on every version, so the
state falls back to '{}'. The test no longer seeds the state file, which
worked around this, and runs the order on a state file that is missing, empty,
blank, an array and an object holding another request, mailing once and then
nothing each time. A fragment in .changelog/ notes the fix.

Validation: tests/permission-request.sh passes on jq 1.6, 1.7.1 and 1.8.2; the
old script fails it on 1.6 ("missing: want one mail") and passes on 1.7.1;
shellcheck and the changelog v2 checker are clean.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review left a comment

Review of b11c866300 for gascitypacks-iq1. Checks of the head: success.

Verdict

pass

Findings

  • None blocking and none minor. roles/assets/scripts/permission-request.sh:61 now validates the state slurped (jq -es 'length == 1 and (.[0] | type == "object")'). A missing, empty or blank state becomes [], which fails on every jq version, so the state falls back to {}. Two concatenated values, a non-object and malformed JSON also fall back. Everything after that line now always works on a valid object. This is one changed line in an existing script, so it adds no new shell logic.

Verified

  • Requirement (work bead gascitypacks-iq1 and its notes): the order mails each request on jq 1.6 with its state file missing, empty or present. The test's seeding workaround is removed, and the test covers the states and prints jq --version when it fails (its fail already did). The changelog note is a fragment. The PR description says which jq the Mac's supervisor runs (Homebrew 1.8.2, ahead of /usr/bin) and that the live order has been mailing. All of this is met. The diff touches nothing unrelated.
  • tests/permission-request.sh: the seeding is gone. check_state runs the order twice per case: one mail for the Worker's request, from controller, never as human, then none on the second run. The cases are a state file that is missing, empty, blank, [], and an object that already holds another entry. In the last case the test checks that both keys are kept after the 24-hour prune; the future date keeps the seeded entry.
  • The merge of the head into the current origin/main (8a95663) is clean, and the forge reports mergeable.
  • Ran in a clean clone with the city's variables removed (env -i, 0 such variables). The scripts job passes: worktree-setup, worktree, gnu-tools, merge, handover, apply, upgrade, view-beads, view-mail, permission-deny, permission-request. The lint job passes: gc lint . with a throwaway HOME, formula, reviewer and operator-overlay, go vet ./..., and go test ./.... tests/permission-request.sh also passes on the system jq 1.7.1-apple, besides Homebrew's 1.8.2. shellcheck is clean on both changed scripts. The changelog checker, built from sarak.sh/mikluko/changelog/v2@v2.1.0, reports valid=true with -base=main.
  • I could not run jq 1.6 here: none is installed, and I run no downloaded binary. The head's CI run 1803 passed all three jobs (lint, scripts, changelog). Its scripts job runs tests/permission-request.sh on the runner whose jq 1.6 showed the bug in #49. jq 1.6's -s gives [] on no input, so the new check fails there as intended.
Review of b11c8663006edb6f42c9be0b7be8d8dae86bd154 for gascitypacks-iq1. Checks of the head: success. ### Verdict pass ### Findings - None blocking and none minor. `roles/assets/scripts/permission-request.sh:61` now validates the state slurped (`jq -es 'length == 1 and (.[0] | type == "object")'`). A missing, empty or blank state becomes `[]`, which fails on every jq version, so the state falls back to `{}`. Two concatenated values, a non-object and malformed JSON also fall back. Everything after that line now always works on a valid object. This is one changed line in an existing script, so it adds no new shell logic. ### Verified - Requirement (work bead gascitypacks-iq1 and its notes): the order mails each request on jq 1.6 with its state file missing, empty or present. The test's seeding workaround is removed, and the test covers the states and prints `jq --version` when it fails (its `fail` already did). The changelog note is a fragment. The PR description says which jq the Mac's supervisor runs (Homebrew 1.8.2, ahead of `/usr/bin`) and that the live order has been mailing. All of this is met. The diff touches nothing unrelated. - `tests/permission-request.sh`: the seeding is gone. `check_state` runs the order twice per case: one mail for the Worker's request, from controller, never as human, then none on the second run. The cases are a state file that is missing, empty, blank, `[]`, and an object that already holds another entry. In the last case the test checks that both keys are kept after the 24-hour prune; the future date keeps the seeded entry. - The merge of the head into the current `origin/main` (8a95663) is clean, and the forge reports `mergeable`. - Ran in a clean clone with the city's variables removed (`env -i`, 0 such variables). The scripts job passes: worktree-setup, worktree, gnu-tools, merge, handover, apply, upgrade, view-beads, view-mail, permission-deny, permission-request. The lint job passes: `gc lint .` with a throwaway HOME, formula, reviewer and operator-overlay, `go vet ./...`, and `go test ./...`. `tests/permission-request.sh` also passes on the system jq 1.7.1-apple, besides Homebrew's 1.8.2. `shellcheck` is clean on both changed scripts. The changelog checker, built from sarak.sh/mikluko/changelog/v2@v2.1.0, reports `valid=true` with `-base=main`. - I could not run jq 1.6 here: none is installed, and I run no downloaded binary. The head's CI run 1803 passed all three jobs (lint, scripts, changelog). Its scripts job runs `tests/permission-request.sh` on the runner whose jq 1.6 showed the bug in #49. jq 1.6's `-s` gives `[]` on no input, so the new check fails there as intended.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
mikluko/gascitypacks!70
No description provided.