Skip to content

park and resume refuse a flag given an empty value in the same words as one given none, so --lane "" no longer parks with the lane dropped and --repo "" no longer falls back to the walk-up - #17

Merged
brettheap merged 3 commits into
mainfrom
fix/flags-refuse-empty-value
Sep 11, 2026

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

The follow-up #14 owed to Copilot, whose review posted one minute after that PR merged. ${2:?…} rejected an unset OR empty value; the [ $# -ge 2 ] that replaced it only checks that an argument slot exists, so an empty one was let through and read further down as "was this given at all?": park --lane "" exited 0 having run make park with the lane silently gone from the WIP commit subject, --repo "" fell past the --repo branch of the resolver into the walk-up, and resume --workspace "" on a machine with a config skipped the never-silently-replaces-an-existing-config check. All seven value-taking arms in park and resume now ask [ $# -ge 2 ] && [ -n "$2" ] and refuse in the same words as before (which already read right for both halves), exit 2; the comment block in each file says why an empty value is the same refusal. Nine parametrized tests beside #14's own, run from INSIDE an estate so the walk-up is there to be fallen back to. With park/resume from main all nine fail, in two ways: park's four at exit 0 with ARGS=[] (the lane gone, make park run), resume's five at exit 2 with no workspace record is configured instead of the flag's own refusal (the estate had been resolved from the cwd; they died at the workspace record). With this change: exit 2, the command's own message, empty stdout.

The second commit brings status's two value-taking arms (--repo, --name | --project) to the same guard: they were arity-only from status's first commit rather than ${2:?}, so Copilot never saw them, but status --repo "" reported the estate around the cwd as though --repo had not been given, and status is the one command where a wrong answer changes nothing and so is never looked at twice. After this PR the three commands agree about what an empty value means. The third commit, from the independent review, adds a hygiene test that reads the three files as text and asserts every line taking $2 into a variable carries the whole guard within the three lines above it, and that there are exactly nine such lines: this bug shipped twice by two routes (83a1601 into park/resume, fbf6f11 into status from its first commit) and was caught both times only by an outside reviewer, because each command's own tests ask what a refusal says and an arm that does not refuse says nothing. With status from main that test fails naming the line. Suite: 261 passed, 0 skipped.

Caller-facing: a wrapper doing park --lane "$LANE" with an empty $LANE parked before and is refused now, exit 2; likewise --repo "$SLUG", --org "$ORG", status --name "$N". The spelling that passes the flag only when there is a value is ${LANE:+--lane "$LANE"}.

Out of scope and reported for a ruling: a value beginning with - is still accepted by every arm, as it was under ${2:?}, so park Atlas --lane --dry-run hands the extension a lane literally named --dry-run and runs a real park. Refusing -* values would foreclose a legitimate dash-led value, and these arms have no = form to escape through, so that is a decision, not a fix.

🤖 Generated with Claude Code

Summary by Sourcery

Refuse empty values consistently across park, resume, and status so they cannot be mistaken for omitted flags or trigger unintended estate resolution.

Bug Fixes:

  • Reject empty values for all value-taking flags in park, resume, and status instead of silently treating them as omitted and continuing with fallback behavior.

Enhancements:

  • Standardize empty-value handling across the estate commands with consistent command-level refusal messages, exit status, and no command output or side effects.

Tests:

  • Add parameterized coverage ensuring every park and resume value-taking flag refuses an empty value.
  • Add coverage for empty values passed to status's repository, name, and project flags.
  • Add hygiene checks confirming all value-taking argument arms use empty-value guards and remain fully accounted for.

…rds as one given none, so `--lane ""` no longer parks with the lane dropped and `--repo ""` no longer falls back to the walk-up

${2:?…} rejected an unset OR EMPTY value; the [ $# -ge 2 ] that replaced it in #14 only checks that an argument slot exists, so an empty one was let through and then read further down as "was this given at all?" — park --lane "" exited 0 having run make park with ARGS=[], the lane silently gone from the WIP commit subject, and --repo "" fell past the --repo branch of the resolver into the walk-up, which is the one thing naming a clone's origin was there to prevent; resume --workspace "" read as a machine nobody had named a workspace to. All seven value-taking arms now ask [ $# -ge 2 ] && [ -n "$2" ] and refuse in the same words, which already read right for both halves; the comment block in each file says why an empty value is the same refusal. Nine more parametrized tests beside #14's own, run from INSIDE an estate so the walk-up is there to be fallen back to: exit 2, the command's own message, and an empty stdout as the proof that nothing was resolved, said or run. Copilot's review of #14, which posted a minute after it merged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 13:22

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 3 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes empty arguments equivalent to missing values for value-taking options, preventing silent flag loss and unintended estate/workspace fallback across park, resume, and status; it adds comprehensive parameterized regression tests for the park/resume behavior.

File-Level Changes

Change Details Files
Reject explicitly supplied empty values consistently across all value-taking flags in park and resume.
  • Replace arity-only checks with presence-and-nonempty checks for nine flags.
  • Preserve command-specific refusal wording and exit status 2.
  • Document why empty values are equivalent to missing values and must fail before resolution or side effects.
park
resume
Add parameterized regression coverage proving missing and empty flag values follow the same refusal path.
  • Centralize the complete list of value-taking park and resume flags for both test cases.
  • Run empty-value cases from inside an estate to detect unintended walk-up resolution or command execution.
  • Assert exit 2, command-specific diagnostics, no stdout, and no filesystem side effects.
tests/test_park_resume_commands.py
Apply the same empty-value validation rule to status's repository and name/project options.
  • Guard --repo and `--name
--project` values against empty arguments so they no longer fall back to cwd-based resolution.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

status still accepts empty values without the promised validation or tests.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR rejects empty option values for park and resume, with regression coverage. The described status parity change remains unimplemented.

Changes:

  • Validate non-empty values for park and resume.
  • Add parameterized empty-value tests.
  • status still needs equivalent validation and coverage.
File summaries
File Reviewed changes
tests/test_park_resume_commands.py Adds empty-value regression coverage for park and resume.
resume Rejects empty option values.
park Rejects empty option values.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_park_resume_commands.py Resolved
… two arms Copilot's review of #14 never had in front of it — so `status --repo ""` no longer reports the estate around the cwd

These two were never ${2:?…}: they have been [ $# -ge 2 ] since status's first commit (fbf6f11), so the review that caught the arity-only check in park and resume — where it had just replaced ${2:?…} — never saw this file, and it kept the hole the other two closed in 8320472. It is the same hole: an empty value is read further down as "was this given at all?", so status --repo "" exited 0 having fallen past the --repo branch of the resolver into the walk-up and reported the estate around the cwd as though the flag had never been typed. A read-only report of the wrong estate is worse than a refusal, not better — nothing was changed, so nobody looks twice. Both arms now ask [ $# -ge 2 ] && [ -n "$2" ] and refuse in the words they already used; the shared resolver and expand_home are untouched, byte for byte. Three more cases in test_refusals_read_nothing, one per flag spelling, run from INSIDE the estate so the walk-up is there to be fallen back to: exit 2, the command's own message, an empty stdout, and that test's own "a refusal read nothing" over all six results. PR #17.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 13:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Empty values are rejected consistently with regression coverage across all reviewed commands.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…value-taking arms of `park`, `resume` and `status`, so the arity-only arm cannot ship a third time

The independent review of #17 asked for it, and the history is the argument: the arity-only arm reached main twice — park and resume at 83a1601, status at fbf6f11, its first commit — and an outside reviewer caught it both times, because each command's own tests ask what a refusal SAYS and an arm that does not refuse says nothing for them to read. This one reads the three files as text, beside that file's other command-text tests: every line taking $2 into a variable must carry [ $# -ge 2 ] && [ -n "$2" ] within the three lines above it, with whole-line comments dropped by code_lines first so the three that QUOTE the idiom in order to explain it cannot stand in for the guard they describe; and the count of nine is asserted by hand, so a tenth arm arrives as a failure somebody reads rather than as a silent pass. It needs neither the submodule nor a shell, so it runs in a clone made without --recurse-submodules and on Windows. Two nits from the same review: resume's --workspace comment no longer joins two different branches with "so" — with a config already here the empty slug slips past the refusal that never silently replaces one, with none it reaches the refusal that says none is configured, which is the branch the tests exercise; and the status empty-value loop gains the "bash's own message leaked" assertion its park/resume twin already had. PR #17.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI review requested due to automatic review settings September 11, 2026 13:41
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Empty-value handling is consistently guarded and covered by regression and hygiene tests.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@brettheap
brettheap merged commit 9d4c8ae into main Sep 11, 2026
7 checks passed
@brettheap
brettheap deleted the fix/flags-refuse-empty-value branch September 11, 2026 13:49
brettheap added a commit that referenced this pull request Sep 14, 2026
… Atlas --lane --dry-run` no longer parks with the lane set to `--dry-run` — and `--flag=value` is the spelling that gives a `-`-led value back, read through one `flag_value` held byte-identical in `park`, `resume` and `status`

Two commits, the second the fix round of this branch's independent review. The two halves of the first are ONE commit because neither is safe alone.

THE HOLE, and what it cost. Every value-taking arm tested `[ $# -ge 2 ] && [ -n "$2" ]`, which asks whether a second argument EXISTS and whether it is non-empty and never what it HOLDS — so `park Atlas --lane --dry-run` ran a REAL park with the lane set to `--dry-run`: the flag a person typed was swallowed as a value, `--dry-run` itself never took effect, and the only sign was a WIP commit subject labelled with it. PR #17 named the hole and left it open; this is the ruling made against something concrete, and if it goes the other way the whole of it is one revert. Proved again on this base, in a temp estate with a probe Makefile, against origin/main's OWN three commands: `park Atlas --lane --dry-run` printed `make park ARGS='--lane --dry-run'` and RAN it, exit 0; `resume Atlas --org --dry-run` went past the rehearsal it was asked for and on to the workspace record, which on a machine that has one is a clone; `status --name --fetch` fetched nothing and refused about an estate named `--fetch`. After: each is `REFUSED: <flag> needs a value: …`, exit 2, from the argument loop with an EMPTY stdout, and the refusal's own sentence names the spelling that does take such a value. THE TWO HALVES ARE ONE COMMIT because refusing `-*` alone takes a value away with nowhere to put it, and the refusal's words name the `=` spelling as the exit, so the exit has to exist the moment the refusal does. All nine value-taking arms — `park`'s `--lane`, `--repo`, `--name | --project`; `resume`'s `--repo`, `--workspace`, `--org`, `--name | --project`; `status`'s `--repo`, `--name | --project`, none of them in the shared estate resolver — read their value through `flag_value`, a new function held BYTE-IDENTICAL in the three files the way `expand_home` already is, and OUTSIDE that block for the reason its own header gives: the resolver answers "which estate is this", and this answers "did this flag get a value". It asks the arity question #14 asked, the emptiness question #17 added, and one more: a next argument beginning with `-` is a flag, and nothing here swallows the next word whatever it is. Each arm keeps its own words and its own `die` at exit 2; the `-`-led refusal adds one sentence naming the spelling that does take such a value, asserted per flag so a hint cannot name the wrong one. `--flag=value` takes whatever follows the FIRST `=` and asks nothing about it, so `--lane=--weird` and `--repo=https://…` both arrive whole; `--flag=` is an empty value and is refused as #17 refuses `""`. `park Atlas --lane=--dry-run --dry-run` gives `ARGS='--dry-run --lane --dry-run'` — the rehearsal flag and the `-`-led lane both through — and `status --name=--fetch` is read as a NAME, refused as "no estate named '--fetch'" and not as a flag. THE STANDARD'S OWN PYTHON HAS ALWAYS DONE THIS: openRepoShape's `scripts/repo_shape.py` (`checked_value`, "ARGUMENT INJECTION IS THE THREAT … A value that begins with `-` is therefore refused outright") and `setup-project.py` refuse a `-`-led value, and their argparse entry points take `--flag=value` for free; the standard's bash front door, `openRepoShape --org`, does not yet — `ORG="${2:?--org needs a value}"`, no `=` arm, still so at the pinned `ba14e1d` — and that is a pull request THERE, then a pin bump here. Each `--help` gains one line for the `=` spelling and nothing else. Tests: eighteen parametrized command cases across `park` and `resume` (nine flags, a `-`-led value refused with nothing run, the `=` form byte-for-byte the same run as the spaced one, `--flag=` refused), plus `status`'s own three flags in both shapes, `park`'s lane case end to end, `resume --workspace=` / `--org=` doing the work those flags name rather than being echoed, and two hygiene tests. Suite at the branch tip, which adds no test after this commit: 571 passed, 0 skipped.

The fix round of the independent REPORT-ONLY review of this branch (2026-09-11; 168 runs across the twelve flag spellings and fourteen forms, main against the branch: every accepted form byte-identical to the spaced one, every `-`-led value refused with an empty stdout, the `--` passthrough and the no-value flags unchanged; verdict MERGE AFTER FIXES), every finding taken. THE ONE THAT MATTERED: `test_every_value_taking_arm_reads_its_value_through_flag_value` counted only arms that read `$FLAG_VALUE`, so a TENTH arm written the old way — `X="$2"`, no emptiness test, no `-` test, no `=` spelling — would have left the count at nine and PASSED the suite, where the test it replaced had caught exactly that. It now names any `="$2"` outside `flag_value` itself, and the count is still nine and still hand-kept, so a tenth arm is read rather than silently passed; re-proved on THIS base by injecting such an arm into a scratch copy of `park` — `AssertionError: park: TENTH="$2"; shift 2 ;; takes $2 straight from the command line`. THE SECOND: for `--lane` the `=` spelling buys `park`'s own parsing and NOT the extension's — the recipe word-splits `$(ARGS)`, so `--lane=--dry-run` hands the extension the same two words the accident did — which the lane test's docstring now says instead of claiming the value "survived"; `park --help`'s example moves to `--repo=<owner/name>`, a value that never leaves the command, and `status --help`'s to `--project=<Name>`, the one value-taking flag its OPTIONS block lists. THE THIRD: `FLAG_VALUE`, `FLAG_SHIFT` and `FLAG_HINT` are declared beside the other globals in all three files, so a `die` that reached `$FLAG_HINT` before any arm had asked prints an empty hint under `set -u` rather than "unbound variable" at exit 1 — the one exit these arms must not produce; unreachable today, since every arm asks first, and cheap to keep that way. Suite: 571 passed, 0 skipped.

BASED ON THE MAIN OF THE MOMENT. The branch was built on `a40cbb7` and rebased onto `8a36eb3` for this first push — 35 commits, in four steps as `main` moved under it, and NOT ONE CONFLICT at any of them: `park` and `resume` had not moved on `main` at all (both byte-identical to `a40cbb7`'s), and `status`'s growth from 2,619 lines to 5,767 lands BETWEEN the regions these commits edit — the globals at line 102 and the OPTIONS block at 222 above it, `flag_value` and the argument loop at 5,631 and 5,704 below it. Every number here is the re-measurement on that base, not one carried over. THE BITE: all 24 of these tests FAIL against origin/main's own `park`, `resume` and `status` — the 23 the first commit adds and `status`'s own `test_refusals_read_nothing`, which took the flag-shaped readings — measured in a scratch tree with main's three commands dropped in beside this branch's tests: `24 failed, 436 passed`. Suite on the branch: 571 passed, 0 skipped, against main's 549 collected; 23 test ids added, one renamed away (`test_every_value_taking_arm_refuses_an_empty_value`, which this replaces). INVARIANTS, each asserted by the suite and checked again by hand: the shared estate resolver byte-identical across the three AND byte-identical to main's, because this branch does not touch it; `expand_home` byte-identical in `status` and `resume`; `flag_value` byte-identical in all three, which is the new test; `bash -n` clean on all three; no `${x,,}`, `mapfile`, `declare -A` or `local -n`, so it parses under macOS bash 3.2; every `"${arr[@]}"` guard is main's own, since this branch adds no array. NO CAP MOVES: README.md and AGENTS.md are untouched and still sit exactly at their caps, 409 and 224.

Ruling: "ruling (c): take dash-values as built, push and PR" — Brett Heap, 2026-09-14.

Lane: openrepotools-3 (openRepoTools-3)

PR #37

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants