Skip to content

fix(fleet): restore-row-count-diff.sh missing option value crashes with an unbound-variable error instead of a usage error #12788

Closed

Description

@dezren39

Evidence

scripts/fleet/restore-row-count-diff.sh:41-56 (verified on origin/main 45191b4). The script runs under set -euo pipefail (line 32) and parses options as:

--manifest) manifest="$2"; shift 2 ;;

with no $# -ge 2 guard. Reproduced:

bash scripts/fleet/restore-row-count-diff.sh --manifest
# observed: line 44: $2: unbound variable ; exit=1

Also, --manifest --live /path silently consumes --live as the manifest value and then reports "unknown argument: /path" — a flag accepted as a filename is a misparse the operator cannot see from the error.

Why it matters

The operator-script argument contract (doc/agents/operator-script-argument-contract.md, #3352) requires the whole command line to be declared and strictly parsed before any work, with unaccounted input as a clean usage error at the script's established usage exit code. This script already uses exit 2 for its other usage errors (unknown argument, missing inputs, usage) — this case escapes as a raw bash error with exit 1, so automation cannot distinguish a usage mistake from a runtime failure, and the operator sees a shell internals message instead of usage.

Acceptance criteria

  • --manifest (or --live/--inventory) with no value prints the usage message and exits 2.
  • An option value that begins with -- is rejected as a usage error, not consumed as the value.

Dedupe

No open or closed issue/PR matches; sibling operator scripts that follow the strict pattern were checked for comparison.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    effort/sSmall: expected under 2 hours of work
    on Nov 23, 2026
  2. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Pickup — xaltha lane taking this slice.

    Plan: reproduce the --manifest unbound-variable crash, fix the option parsing in scripts/fleet/restore-row-count-diff.sh so a missing value (or a value beginning with --) is a clean usage error at exit 2, and add a regression check that fails before and passes after. Branch: xaltha/12788-restore-row-count.

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress — fix landed as PR #13040 (#13040), Closes #12788.

    Evidence:

    • Before: bash scripts/fleet/restore-row-count-diff.sh --manifest → line 44: $2: unbound variable, exit 1; --manifest --live /path consumed --live as the value and reported unknown argument: /path.
    • After: --manifest / --live / --inventory with no value, and a value beginning with --, all print option <name> requires a value + the usage message and exit 2; a well-formed run still passes the gate.
    • Regression test scripts/tests/test_restore_row_count_diff.py (4 tests) failed before the fix and passes after; wired into scripts-test.yml and registered in .github/test-suite-registry.json (sibling pattern: provider-retirement-gate). check-suite-registry.sh reports no new violations.

    Files: scripts/fleet/restore-row-count-diff.sh, scripts/tests/test_restore_row_count_diff.py, .github/workflows/scripts-test.yml, .github/test-suite-registry.json. Commit f3e9d659f on xaltha/12788-restore-row-count.

  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Shepherd claim — Lane QF (archer) taking PR #13040 to completion.

    Ownership check (fresh REST reads, 2026-11-23 ~09:47Z): xaltha picked this up 07:30Z and landed the fix as PR #13040 with full evidence by 07:33Z; Codex review completed with no findings; no activity on the PR or this issue since 07:33Z and no record that xaltha reserved the finish. Treating the shepherd leg as idle and carrying it: verify at head f3e9d659fcc2719900fff935e7e109e20ab24e24 (run the declared oracle python3 -m unittest discover -s scripts/tests -p 'test_restore_row_count_diff.py' plus the suite-registry check), then merge SHA-guarded at that head if green.

  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Done — shepherd complete. PR #13040 merged (12903113342a819c228c6c49864e4274d9e65b46, head SHA-guarded at f3e9d659fcc2719900fff935e7e109e20ab24e24); #12788 verified CLOSED as completed.

    Verification at the PR head (laptop worktree, exact SHA):

    • Declared oracle python3 -m unittest discover -s scripts/tests -p 'test_restore_row_count_diff.py' → 4 tests, OK.
    • bash .github/scripts/check-suite-registry.sh → exactly the 3 pre-existing unwired-suite violations the PR body named (atlas_content_profile_vectors.rs, location_ref.rs, exchange_lock_release.rs — the id: register the 36 test suites that no registry row names #12230 gaps, since fixed on main); the new suite is wired and adds no violation.
    • Mergeability re-read immediately before merging: mergeable: true, clean, head unchanged since xaltha's 07:33Z evidence post. Codex review on the PR: completed, no findings.

    Credit: the fix and its evidence are xaltha's; this lane only verified and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions