Skip to content

id(tags): parse_search_query only separates terms on ASCII space — tab/newline/NBSP fuse terms into one unmatchable term #1609

Closed

Description

@dezren39

Problem

parse_search_query (pkgs/id/src/tags.rs:1466) separates search terms only on the ASCII space byte. A tab, newline, CRLF or non-breaking space between terms fuses them into a single bogus term, so a multi-term tag search silently returns the wrong (usually empty) result instead of the AND of its terms.

The separator checks are byte comparisons against b' ':

  • tags.rs:1478 — the skip-separators loop: bytes[i] == b' '
  • tags.rs:1492 — the term-end check: bytes[i] == b' ' && !in_quotes

Every other splitter in this codebase treats general whitespace as the separator (split_whitespace in directory_view.rs / repl, char::is_whitespace in directory_view::split_first). This parser is the outlier.

Evidence (verified this run)

Verbatim probe crate on the laptop (functions copied unchanged from tags.rs at main 63ba170; tags.rs sha256 c08d87fd identical on sandbox and laptop clones; probe + log in the fleet's hidden_files/probe-2026-10-28-laneA-searchws/):

Controls — all correct:

  • name:foo bar:baz → [KeyValue("name","foo"), KeyValue("bar","baz")]
  • "hello world" name:foo → [Literal("hello world"), KeyValue("name","foo")]
  • "a<TAB>b" name:foo → [Literal("a\tb"), KeyValue("name","foo")] — a tab inside quotes correctly stays part of the literal

Bug cases — terms fuse:

  • name:foo<TAB>bar:baz → [KeyValue("name", "foo\tbar:baz")] — one term whose value can never equal a stored tag value
  • hello<TAB>world → [BareWord("hello\tworld")]
  • name:foo<LF>bar:baz and name:foo<CRLF>bar:baz → same fusion with \n / \r\n in the value
  • hello<NBSP>world → [BareWord("hello\u{a0}world")]
  • name:<TAB>priority → [KeyValue("name", "\tpriority")] instead of the space form's [KeyOnly("name"), BareWord("priority")] (the space behaviour is pinned by the existing test at tags.rs:~2479, test_parse_search_multiple_terms)

Consequence at the call site: search_by_query (tags.rs:1304) runs find_by_key_value / contains-matching with the fused value/word, which matches no stored tag, and the AND intersection then yields an empty result set — the search reports "no matches" for tags that exist.

Reachability: the HTTP search endpoint GET /api/tags/search?q= (web/tags_ws.rs:434-448) and the meta protocol SearchTags request (protocol.rs:629) pass the raw query string straight to search_by_query. A query pasted from a terminal, spreadsheet or document routinely carries tabs or newlines between terms. (The CLI/REPL paths join argv tokens with single spaces at commands/tag.rs:199 and repl/runner.rs:398, so they do not produce these separators themselves.)

Why it matters

Tag search is the structured query surface for the whole namespace. A pasted query failing silently — empty results, no error, no hint that the separator was the problem — reads as "these tags don't exist" and sends the user debugging their data instead of their query string.

Acceptance criteria

  • Term separation in parse_search_query recognises general whitespace (at minimum tab, LF, CR and NBSP — i.e. char::is_whitespace semantics), not only ASCII space, both when skipping separators and when ending a term.
  • Whitespace inside a quoted section remains part of that term (the "a<TAB>b" control above still parses as one Literal).
  • New unit tests next to the existing parser tests pin: tab-, newline- and CRLF-separated key:value terms, a tab-separated bare-word pair, and name:<TAB>priority matching the space form.
  • All pre-existing parse_search_query tests pass unchanged.

Activity

  1. developing-today commented on Oct 28, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Oct 28, 2026
  3. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (new-issue-creator-code-a)
    • Session / ID: new-issue-creator-code-a cron run, 2026-10-28 01:05 CDT
    • Found via: filed this run
    • Task: Triage the ASCII-space-only term separation in parse_search_query (pkgs/id/src/tags.rs:1478/:1492): tab/newline/CRLF/NBSP fuse terms into one unmatchable term, so a pasted multi-term tag search silently returns empty. Verified with a verbatim probe on the laptop (tags.rs sha256 c08d87fd identical both sides; controls incl. quoted-tab Literal all correct).
    • Expectation: effort/s — one behaviour pinned (general-whitespace separation, quoted whitespace preserved), parser tests added per the acceptance criteria.
    • Links: queue packet packet-1609.json (repo-health-code-pilot, triage)
  4. added
    queue/claimedQueue worker lifecycle state
    and removed on Oct 28, 2026
  5. 48 remaining items

  6. added
    status/parkedDeliberately paused with a recorded resume condition
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 28, 2026
  7. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    Resumed by queue worker Lane A (task 1850): PR #1743 already implemented and pushed from a prior shift; checking CI fresh — merge if green per standing criteria, otherwise re-park.

  8. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done — fixed & merged

  9. dezren39 commented on Oct 28, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · correction — PR #1743 has a real CI failure (clippy-lint)

    • Agent: repo-worker-code (lane C)
    • Session / ID: queue task 1850, scheduled shift 2026-10-28 13:11 CDT (post-shift correction)
    • Correction: the park note above said "26/32 pass, 0 fail". A later-completing poll from the same shift, re-verified fresh after the shift, shows the finished picture on PR fix(id/tags): parse_search_query separates terms on general whitespace (#1609) #1743 @ 54e6cf9: 32/33 checks complete with nix flake check (clippy-lint) = FAILURE (the remaining aggregate "nix flake check" rolls up from it). The clippy job was still running when the earlier snapshot was taken. All other completed checks pass, including cargo-check and the test shards.
    • Resume (supersedes the merge-if-green line above): do NOT merge. Reproduce the clippy failure on branch queue/1850-1609-search-whitespace (laptop: cargo clippy for the id crate / read the failed job's log first), fix it, re-push, and only merge once the full set is green.
    • Links: PR fix(id/tags): parse_search_query separates terms on general whitespace (#1609) #1743 · queue task 1850 (parked, resumes ~20 min after 18:42Z park)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions