Repository navigation
Description
Problem
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 REPLfind,search, andshow): when the token after--first/--lastdoes not start with-and failsparse::<usize>(), the branch setsfirst/last = Some(1)("default to 1") but does not consume the token (i += 1happens only on parse success). The loop then reaches that same token, it does not start with-, and the final branch pushes it intoargs.queries.pkgs/id/src/repl/runner.rs:1190-1213—parse_peek_argsrepeats the identical--first/--lastshape, with the same fall-through intofind_args.queries.pkgs/id/src/repl/runner.rs:1216-1223—parse_peek_args'--lines/-nbranch is worse in one way: on parse failure it sets nothing and consumes nothing, so the bad token again becomes a query andlinessilently 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/--lastinparse_find_argsandparse_peek_args, or following--lines/-ninparse_peek_args, is never added toqueriesand 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 (
--firstwith no following token, or followed by another flag) keeps its documented default of 1. - Regression tests in
runner.rscover at least:["q", "--first", "two"],["q", "--last", "abc"], and peek["q", "--lines", "abc"]— asserting the bad token is not inqueriesand 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).
Activity
developing-today commentedon Oct 29, 2026
CODE-930
dezren39 commentedon Oct 29, 2026
🤖 Agent note · filed
--first/--last/--linesnon-numeric value silently becomes a search query and the limit silently defaults — verified with a verbatim-branch probe on the laptop (main d069a61)~/git/fleet/probe-2026-10-28-laneA-replfirst/(laptop)4 remaining items
dezren39 commentedon Nov 1, 2026
🤖 Agent note · done
cargo test --lib repldid not reach test execution; both attempts timed out while compiling dependencies.dezren39 commentedon Nov 1, 2026
🤖 Agent note · picked up
--first/--lastvalues in both parsers and invalid peek--lines/-n; preserve bare--first/--lastdefaulting to 1.dezren39 commentedon Nov 1, 2026
🤖 Agent note · done
--first/--lastvalues now error in both parsers; invalid peek--lines/-nvalues error before search; bare first/last defaults remain 1.cargo test --lib replpassed (140 id tests + 3 id_core tests); targeted rustfmt and diff checks passed.fix(id/repl): keep output redirection after bare --first/--last (#2009)
fix(id/repl): reject nonnumeric result limits (#4072)