permission-request order mails nothing on jq 1.6 when its state file is missing or empty #70
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!70
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-iq1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes
gascitypacks-iq1: thepermission-requestorder 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 oftests/permission-request.shon the CI runner in #49.Change.
roles/assets/scripts/permission-request.shvalidates 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.shno 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.failstill printsjq --version..changelog/permission-request-jq16.md: aFixedfragment.Checked.
tests/permission-request.shpasses on jq 1.6, 1.7.1 and 1.8.2.missing: want one mail) and passes on 1.7.1, so the test catches the bug.shellcheckand the changelog v2 checker are clean.The live order. The Mac's supervisor has
/opt/homebrew/binahead of/usr/binon 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
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>Review of
b11c866300for gascitypacks-iq1. Checks of the head: success.Verdict
pass
Findings
roles/assets/scripts/permission-request.sh:61now 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
jq --versionwhen it fails (itsfailalready 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_stateruns 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.origin/main(8a95663) is clean, and the forge reportsmergeable.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 ./..., andgo test ./....tests/permission-request.shalso passes on the system jq 1.7.1-apple, besides Homebrew's 1.8.2.shellcheckis clean on both changed scripts. The changelog checker, built from sarak.sh/mikluko/changelog/v2@v2.1.0, reportsvalid=truewith-base=main.tests/permission-request.shon the runner whose jq 1.6 showed the bug in #49. jq 1.6's-sgives[]on no input, so the new check fails there as intended.