beads/internal/query
Isis Anisoptera 40b7f75c26
fix(query): make slash and mixed-case metadata keys queryable (#4896)
* fix(metadata): allow / in metadata keys

ValidateMetadataKey rejected slashes even though keys are always passed
as bind parameters and JSONMetadataPath quotes non-identifier keys, so
the restriction had no safety purpose. Allow / in the key charset and
quote slash keys in JSON paths (unquoted, / is a path syntax error).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B

* fix(query): make slash metadata keys queryable; always quote JSON paths

Code-review follow-ups to the / metadata-key change:

- Allow / in query-language identifiers so keys like jira/sprint are
  reachable from 'metadata.jira/sprint=42' expressions, not just the
  --metadata-field flag.
- JSONMetadataPath now quotes every key unconditionally (valid for plain
  keys too), removing the separator char list that had to stay in sync
  with validMetadataKeyRe.
- Derive the ValidateMetadataKey error message from the regex itself.
- Collapse the five JSONMetadataPath clone tests into one table-driven
  test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B

* test(query): enforce that all valid metadata keys are queryable

Sweep every printable ASCII character and assert each key accepted by
storage.ValidateMetadataKey parses as metadata.<key>=<value>, so the
lexer's identifier alphabet and the storage key regex can't drift apart
and silently recreate the unqueryable-key bug class.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B

* fix(query): preserve metadata key case; escape JSON path keys

Review follow-ups on this branch:

- The parser lowercased the whole field token, so mixed-case metadata
  keys (valid per ValidateMetadataKey, stored case-sensitively) were
  silently unqueryable via metadata.<key>=<value> — and inconsistent
  with has_metadata_key and the --metadata flag, which preserve case.
  Keep field-name matching case-insensitive but restore the key
  suffix's original case.

- JSONMetadataPath spliced the key into the quoted path unescaped,
  relying on every caller validating first. Escape \ and " locally so
  the function is correct for any input.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019jrTawz2CRUiJLCt2UTQ2B

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 17:52:22 -07:00
..
evaluator.go feat(issues): add started_at timestamp (GH#2796) (#3206) 2026-04-14 09:24:08 -07:00
lexer.go fix(query): make slash and mixed-case metadata keys queryable (#4896) 2026-07-24 17:52:22 -07:00
parser.go fix(query): make slash and mixed-case metadata keys queryable (#4896) 2026-07-24 17:52:22 -07:00
query_test.go fix(query): make slash and mixed-case metadata keys queryable (#4896) 2026-07-24 17:52:22 -07:00