GeezerVison is showing github.com — id(find/search/show/peek): a zero count is accepted everywhere — '--first 0'/'--last 0' report 'no matches found' for queries that do match, and 'peek --lines 0' renders a preview with no content lines · Issue #3059 · developing-today/code
id(find/search/show/peek): a zero count is accepted everywhere — '--first 0'/'--last 0' report 'no matches found' for queries that do match, and 'peek --lines 0' renders a preview with no content lines #3059Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes 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 jobtask/triageQueue packet kind: verify, reproduce, and route this item Descriptionid(find/search/show/peek): a zero count is accepted everywhere — --first 0/--last 0 report 'no matches found' for queries that do match, and peek --lines 0 renders a preview with no content lines
Problem
Every count-taking flag in the find/search/show/peek family accepts 0, and 0 silently produces an empty or content-free result that blames the query instead of the limit:
- CLI (
pkgs/id/src/cli.rs): first/last are plain Option<usize> with num_args = 0..=1 (e.g. :727/:730) and peek's lines is a plain usize (:783) — no range validation anywhere, so id find --first 0 config and id peek --lines 0 readme parse cleanly.
- REPL (
pkgs/id/src/repl/runner.rs): parse_find_args (--first branch :672-686, --last :687-701) and parse_peek_args (the duplicated --first/--last :1190-1213, --lines :1217-1224) accept a parsed 0 exactly like any other number.
- The limit itself (
pkgs/id/src/commands/find.rs:137-145, SearchOptions::apply; REPL copy apply_search_options at runner.rs:987+): first = Some(0) is take(0) and last = Some(0) is skip(len - 0) — both yield an empty match list.
- The handlers then misreport it: CLI
find.rs:253 bails no matches found for: <query> and the REPL handlers print the same line (runner.rs:750, :811, :863, :911) — a user whose query does match is told it doesn't, with no hint the zero limit emptied the list.
- Peek renders nothing:
print_peek_lines (runner.rs:1278+) with lines = 0 takes the total_lines <= n * 2 false branch for any non-empty file, prints the banner plus ... (N more lines) and ... (N lines above) and zero content lines — a "preview" containing no preview.
Verified this run (2026-10-31, main 1f8ab4f6)
Probe compiled and run on the laptop (~/git/fleet/probe-2026-10-31-laneB-zero/ there; the --first/--last parse branches, the SearchOptions::apply limiting, and the print_peek_lines head/tail logic copied verbatim from runner.rs/find.rs; sandbox copies md5 ee82b58f runner.rs, b64b2ede find.rs):
- Control
["report", "--first", "2"] → first=Some(2), apply over [1,2,3] = [1, 2] ✓
["report", "--first", "0"] → first=Some(0), apply over [1,2,3] = [] → handler prints no matches found for: report
["report", "--last", "0"] → last=Some(0), apply over [1,2,3] = []
- peek lines core with
n=0, 10-line content → banner + ... (10 more lines) + ... (10 lines above), content lines shown = 0 of 10
Why it matters
This is the silent-reinterpretation class this REPL keeps producing (#2009 non-numeric values becoming queries, #3029 --first+--last discarding --last), one step earlier: the value parses successfully, so nothing looks wrong, yet the answer is empty for a reason the output actively misstates. 0 is the most likely fat-finger/variable-substitution value (--first $N with N unset-ish or computed as 0 in a script), and scripts driving the CLI get a hard no matches found error (bail at find.rs:253) for files that exist.
Acceptance criteria
- A zero count is refused with a message naming the flag at every entry point — CLI
find/search/show/peek (clap range validation or an explicit check) and REPL find/search/show/peek — OR triage pins a documented meaning for 0 and every handler implements it identically; the bare-flag documented defaults (first/last = 1, lines = 5) are unchanged.
- No path from a zero limit reaches the
no matches found wording: with the refusal, find --first 0 <matching query> errors on the limit, not the query.
- Regression tests cover: REPL
parse_find_args/parse_peek_args with --first 0 and --last 0; SearchOptions::apply (or its replacement) never silently empties on a zero that slipped through; peek rendering with the zero case handled per the pinned contract.
- Both parser copies (find/search/show and peek) and both surfaces (CLI and REPL) behave identically — the fix is not applied to only one copy.
Dedup / related
Distinct from #2009 (non-numeric --first/--last/--lines values becoming queries — a rejected parse; here the parse succeeds), #3029 (--first and --last together discarding --last), #2274 (unknown/mistyped flags swallowed), #1999 (selection-prompt numbers). Searched open + closed for zero-count/first-0/lines-0 coverage on 2026-10-31: none.
Filed by new-issue-creator-code-b (Lane B). Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item app/idPackage/app: id (pkgs/ or apps/ in this repo) effort/xsTrivial: expected under 30 minutes of work on Oct 31, 2026dezren39 commented on Oct 31, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (new-issue-creator-code-b, Lane B)
- Session / ID: cron new-issue-creator-code-b, run 2026-10-31 07:50 CDT
- Found via: filed this run
- Task: Triage the zero-count acceptance in find/search/show/peek (--first 0/--last 0 empty the match list and misreport 'no matches found'; peek --lines 0 renders no content lines) and route the fix
- Expectation: effort xs; done = zero counts refused (or a pinned meaning implemented identically) at CLI + REPL entry points with regression tests, per the issue acceptance criteria
- Links: evidence in the issue body; probe on the laptop at ~/git/fleet/probe-2026-10-31-laneB-zero/
dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 🤖 Correction (Lane F, post-shift verification): the test evidence recorded for this PR during the shift was wrong. A test-run transcript in this environment reported "29 passed" for code that did not compile: my patch had inserted parse_result_limit between #[derive(Subcommand, Debug)] and pub enum Command, breaking the id lib-test target (158 errors), and a second run's "2 passed" was likewise not real. An independent re-verification on a fresh checkout of merged main — reading the build log directly — caught it. Fix-forward PR #3754 (merged dad9ddd17) restored the derive placement and also repaired 3 pre-existing uncompilable call sites from PR #3695; the same targeted filters now genuinely pass 182/182 from the log. The #3059 feature code itself is unchanged and its tests (test_cli_rejects_zero_result_limits, test_parse_rejects_zero_result_limits) pass. Apologies for the noise — the shift's other merges (#3725, #3695) were verified by independent means (direct queue/GitHub reads and a separately logged test suite) and are unaffected.
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes 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 jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|