Skip to content

Fix inconsistent repeated-key acceptance across query families (#102) - #143

Merged
thomasfosterau merged 2 commits into
mainfrom
claude/laughing-pasteur-w8h59u
Sep 17, 2026
Merged

thomasfosterau merged 2 commits into
mainfrom
claude/laughing-pasteur-w8h59u

Conversation

@thomasfosterau

Copy link
Copy Markdown
Owner

Summary

Fixes #102: Repeatable (the codec that accepts UrlParams.toRecord's array shape for a repeated
key alongside the comma form) was applied at Query.schema's include only. sort,
fields[TYPE], and the filter grammar's list-valued positions stayed comma-only — two spellings of
the same grammar, one accepted and one rejected, with no principle distinguishing them.

  • Query.schema: sort and fields[TYPE] now widen to Repeatable at the flat wire struct,
    matching include; FlatFields moves with the runtime.
  • Standalone constructors (Query.Include, Query.Fieldset, Query.Sort): compose
    Repeatable under their item codec via a new repeatable helper in internal/codecs.ts — they
    have no flat/nested split to inherit the fix from Query.schema, so they needed it directly.
  • The filter grammar (internal/filter.ts) now accepts a repeated key at its list-valued
    positions (shorthand filter[f], filter[f][op], a group form condition's [value] member),
    rejecting it everywhere else (a group's conjunction, any memberOf, a condition's path/operator)
    exactly as before. FilterWireValue already typed string | string[]; the runtime unconditionally
    rejected arrays regardless.
  • Decision, documented: CommaSeparated/Sort now drop empty comma segments (a,,b, a trailing
    comma) instead of handing them to the item schema as a bogus item. This is a deliberate behavior
    change, not an incidental side effect, so the changeset is minor.

Encoding is unchanged — every family still emits the single canonical comma form, verified with
decode-then-encode round-trip tests through Query.canonical.

Test plan

  • Updated the two tests that previously locked in the old asymmetric behavior (a rejected
    repeated filter key, and "only include is repeatable")
  • Added repeated-key / mixed-form / round-trip coverage for sort, fields[TYPE], the filter
    grammar's list-valued positions, and the standalone Query.Include/Fieldset/Sort
    constructors
  • Added coverage for the empty-comma-segment normalization decision
  • pnpm run check (typecheck + lint + format:check + test, including the examples/* packages)
  • pnpm run docgen (compiles and runs every JSDoc @example)
  • Updated docs/filter-grammar.md and README.md to match
  • Added a changeset

🤖 Generated with Claude Code

https://claude.ai/code/session_01VSKpjhULi2X6jR71XDmrRn


Generated by Claude Code

Repeatable (the codec accepting UrlParams.toRecord's array shape for a
repeated key) was applied at Query.schema's include only, while sort,
fields[TYPE] and the filter grammar's list-valued positions stayed
comma-only - two spellings of the same grammar, one accepted and one
rejected, with no principle distinguishing them.

- Query.schema: sort and fields[TYPE] now widen to Repeatable at the flat
  wire struct, matching include; FlatFields moves with the runtime.
- The standalone constructors (Query.Include, Query.Fieldset, Query.Sort)
  compose Repeatable under their item codec via a new repeatable helper
  in internal/codecs.ts, so they gain the same acceptance directly.
- The filter grammar (internal/filter.ts) accepts a repeated key at its
  list-valued positions (shorthand filter[f], filter[f][op], a group form
  condition's [value] member), rejecting it everywhere else (a group's
  conjunction, any memberOf, a condition's path/operator) exactly as
  before.
- CommaSeparated/Sort now drop empty comma segments (a,,b / a,b,) instead
  of handing them to the item schema as a bogus item - documented as a
  deliberate decision, not an incidental side effect.

Encoding is unchanged: every family still emits the single canonical comma
form, verified by decode-then-encode round-trip tests through
Query.canonical.

Updates the two tests that previously locked in the old asymmetric
behavior, and docs/filter-grammar.md and README to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSKpjhULi2X6jR71XDmrRn
…ur-w8h59u

# Conflicts:
#	src/internal/codecs.ts
@thomasfosterau
thomasfosterau merged commit 43275f1 into main Sep 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The repeated-key query spelling is honoured for include only — ?sort=a&sort=b, ?fields[x]=a&fields[x]=b and repeated filter[…] all fail to decode

2 participants