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
bug: a 400 for a renamed query property names the decoded key in source.parameter, not the wire parameter #305
Found while fixing the review findings on #300 (Refs #282). This predates #300; the follow-up PR for it does not change it.
What's wrong
When a query schema renames a property on the wire, a 400 for a rejected value names the decoded key in source.parameter, not the wire parameter the client sent. JSON:API's source.parameter is "a string indicating which URI query parameter caused the error", so a client that reads it is pointed at a parameter that does not exist.
Middleware.schemaErrorDocument's sourceOf (src/Middleware.ts) builds source.parameter from the issue's path. The issue path is in decoded keys, because Schema.encodeKeys renames the struct in a transformation the error path does not undo.
Reproduction
On trunk bb1a07f, served with Middleware.SchemaErrorsLive:
Expected:"source": { "parameter": "include" }, the wire name the request used.
Actual:"source": { "parameter": "paths" }, the decoded property name.
The same applies to any query family renamed this way. Query.bracketKeys / Query.bracketPageKeys rename keys too (offset → page[offset]), so they are worth checking in the same pass.
Done when
A rejected value in a renamed query property names the wire parameter in source.parameter.
A test pins it for Schema.encodeKeys, and for Query.bracketPageKeys if that is affected too.
Activity
fix(Middleware): read a renamed query by probing its transformation (#…
fix(Middleware): pair a renamed query only where its probes agree (#305)
docs(Middleware): qualify the probe's pairing and interruption claims (…