You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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 #102
internal/codecs.ts ships Repeatable exactly for this, and its own doc comment states the general rule:
JSON:API's comma grammar (?include=a,b) and the repeated-key spelling (?include=a&include=b) denote the same set, and UrlParams.toRecord decodes a repeated key to an array rather than a string.
But Repeatable is applied at exactly one site. In Query.schema:
FlatFields mirrors the same asymmetry at the type level: include is Repeatable, sort / fields[…] / filter[…] are Schema.String.
The consequence: ?sort=-createdAt&sort=title (and the fields / filter equivalents) decode to an array via UrlParams.toRecord, hit a Schema.String field, and the request fails with a 400 — while the identical ?include=a&include=b succeeds. Two spellings of the same grammar, one accepted and one rejected, with no principle distinguishing them.
The standalone constructors have the same gap: Query.Sort(fields) and Query.Fieldset(resource) are bare CommaSeparated / SortCodec, and Query.Include(...) is CommaSeparated too — only the flat schema composed by Query.schema gets the Repeatable treatment for include, so anyone composing a query from the standalone pieces loses even that.
Expected
Every comma-separated query family accepts both spellings and any mix of them, and encodes back to the single canonical comma form:
repeated filter[…] keys where the declared filter is list-valued (FilterWireValue already admits string | string[], so the bare-filter path is closer to right than the per-key filter[x]: Schema.String path)
Repeatable composed under the existing item codecs should be most of the fix; the type-level FlatFields mapping needs the matching change.
Why it matters here
thomasfosterau/website and thomasfosterau/gardeneria both carry a hand-rolled sort parameter for precisely this reason (packages/models/src/sort.ts):
and packages/api/src/resource.ts carries IncludeArray — a second hand-rolled union — with a comment noting the same UrlParams.toRecord behaviour and calling out that a bare Schema.Array(Schema.String) field "rejects the single-value case … the common shape a real client sends". Both are the package's own Repeatable, re-derived downstream because the package applies it inconsistently.
Notes
Also worth deciding while here: ?include=a,,b and a trailing comma. CommaSeparated's splitter keeps empty segments; the downstream consumers audited all filter them out (splitIncludePaths in packages/api/src/resource.ts). Normalising empties away in the package would remove one more re-derivation.
Activity
Merge main into the conformance kit
Merge main into the declared include surface