GeezerVison is showing github.com — id(repl): a non-numeric --first/--last/--lines value silently becomes a search query — 'find report --first two' searches for 'two' too, truncated to 1 · Issue #2009 · developing-today/code
id(repl): a non-numeric --first/--last/--lines value silently becomes a search query — 'find report --first two' searches for 'two' too, truncated to 1 #2009DescriptionProblem
In the id REPL, a non-numeric value after --first / --last (and after --lines in peek) is silently reinterpreted as a search query, and the limit silently falls back to 1 (or, for --lines, to the default 5). No error or warning is printed anywhere — the parsers return only a struct.
pkgs/id/src/repl/runner.rs:675-700 — parse_find_args (used by REPL find, search, and show): when the token after --first/--last does not start with - and fails parse::<usize>(), the branch sets first/last = Some(1) ("default to 1") but does not consume the token (i += 1 happens only on parse success). The loop then reaches that same token, it does not start with -, and the final branch pushes it into args.queries.
pkgs/id/src/repl/runner.rs:1190-1213 — parse_peek_args repeats the identical --first/--last shape, with the same fall-through into find_args.queries.
pkgs/id/src/repl/runner.rs:1216-1223 — parse_peek_args' --lines/-n branch is worse in one way: on parse failure it sets nothing and consumes nothing, so the bad token again becomes a query and lines silently stays at the default 5.
Verified this run (2026-10-28, main d069a613)
Probe compiled and run on the laptop (~/git/fleet/probe-2026-10-28-laneA-replfirst/ there; the --first/--last/query branches and loop increment copied verbatim from parse_find_args):
- Control
["report", "--first", "5"] → queries=["report"] first=Some(5) ✓
- Control
["report", "--first"] → queries=["report"] first=Some(1) ✓ (documented bare-flag default)
["report", "--first", "two"] → queries=["report", "two"] first=Some(1) — the typo became a second search term and the result set was narrowed to 1
["report", "--last", "abc"] → queries=["report", "abc"] last=Some(1)
["--first", "two", "report"] → queries=["two", "report"] first=Some(1)
So find report --first two does not fail, does not warn, and does not search what the user asked: it searches for report AND two, truncated to the first match (apply_search_options, runner.rs:987-1013, applies the limit after collecting matches for all queries).
Why it matters
A one-character-class typo in an interactive session silently changes which blobs are searched for and how many come back — the same silent-reinterpretation class as #1999 (selection prompt dropping unparseable numbers), one parser earlier. The REPL is the surface where users type these flags by hand, so typos are the common case, not an edge case.
Acceptance criteria
- A non-numeric token following
--first/--last in parse_find_args and parse_peek_args, or following --lines/-n in parse_peek_args, is never added to queries and never silently defaults the limit: the command reports the bad value (usage/error line naming the flag and the token) and runs no search, OR the triage-pinned contract is documented in the help text and implemented identically in both parsers.
- The bare-flag form (
--first with no following token, or followed by another flag) keeps its documented default of 1.
- Regression tests in
runner.rs cover at least: ["q", "--first", "two"], ["q", "--last", "abc"], and peek ["q", "--lines", "abc"] — asserting the bad token is not in queries and the failure is surfaced; existing parser tests (runner.rs:1540+) still pass.
- Both parser copies behave identically (find/search/show and peek), so the fix is not applied to only one copy.
Filed by new-issue-creator-code-a. Related: #1999 (same REPL, same silent-parse class, different site). Activitydeveloping-today commented on Oct 29, 2026 added task/triageQueue packet kind: verify, reproduce, and route this item app/idPackage/app: id (pkgs/ or apps/ in this repo) kind/bugSomething isn't working (prefixed form of the classic bug label) effort/xsTrivial: expected under 30 minutes of work on Oct 29, 2026dezren39 commented on Oct 29, 2026 🤖 Agent note · filed
- Agent: new-issue-creator (new-issue-creator-code-a)
- Session / ID: cron new-issue-creator-code-a run 2026-10-28 19:05 CDT
- Found via: filed this run
- Task: REPL
--first/--last/--lines non-numeric value silently becomes a search query and the limit silently defaults — verified with a verbatim-branch probe on the laptop (main d069a61)
- Expectation: effort xs; done when a bad numeric flag value is surfaced (never added to queries, never silently defaulted) in both REPL parsers, with regression tests
- Links: evidence in the issue body; probe
~/git/fleet/probe-2026-10-28-laneA-replfirst/ (laptop)
dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 🤖 Agent note · picked up
- Agent: repo-worker-code (OpenChamber scheduled lane)
- Session / ID: ses_e5e66a8a4b3ffexvJwMlYfwxCT · queue task 5075
- Found via: repo-health-code-pilot atomic claim
- Task: Fix malformed numeric flags in the REPL find/peek argument parsers.
- Expectation: Reject invalid
--first/--last values in both parsers and invalid peek --lines/-n; preserve bare --first/--last defaulting to 1.
- Next: Create the task worktree, inspect current parser/tests, implement scoped regressions, and run targeted REPL tests. Related task 5060 owns selection-prompt parsing in the same file and remains out of scope.
dezren39 commented on Nov 1, 2026 🤖 Agent note · done
- Agent: repo-worker-code (OpenChamber scheduled lane)
- Session / ID: ses_e5e66a8a4b3ffexvJwMlYfwxCT · queue task 5075
- Found via: repo-health-code-pilot atomic claim
- Task: Reject malformed numeric limit flags in the REPL find/peek parsers.
- Outcome: PR fix(id/repl): reject nonnumeric result limits #4072 opened: fix(id/repl): reject nonnumeric result limits #4072. Invalid
--first/--last values now error in both parsers; invalid peek --lines/-n values error before search; bare first/last defaults remain 1.
- Tests:
cargo test --lib repl passed (140 id tests + 3 id_core tests); targeted rustfmt and diff checks passed.
- CI: No pending CI checks at completion; CodeRabbit status was neutral. Issue remains open until PR merge.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|