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
feat(Conformance): a rule that a response to ?include= carries an included key, even empty #256
JSON:API 1.1 §Fetching Includes: when an endpoint supports include and the client supplies it, "the server's response MUST be a compound document with an included key — even if that included key holds an empty array (because the requested relationships are empty)."
The conformance kit has no rule for this. #232 fixes the builders (Handlers.data / Handlers.collection keep an empty included array, and Assemble.* emit included: [] whenever the request carried include), but nothing in CI catches an api that drops the key. The kit's compound probe (documentProbes in src/internal/conformance/spec.ts) already sends ?include= to every endpoint that declares it and learns an includable relationship from the bare response. Its result feeds the full-linkage and duplicate-resource rules, and no rule checks that the response has the key.
This was left out of the #232 PR on purpose: the kit (src/internal/conformance/*, src/Conformance*.ts), docs/conformance.md and examples/*/test/conformance.test.ts were being edited in parallel.
Proposal
Add a spec rule, e.g. spec/document/included-on-include. For every 2xx compound probe the kit sends with include, the body must have a top-level included key that is an array (empty is fine). The finding names the URL and says the key was missing.
Gate applicability like the other compound rules: report Skipped when no compound probe returned 2xx.
Fixture cases: a server that answers ?include= with no included key fails exactly this rule. A server that answers included: [] passes. A response to a request without include that has no included key is not flagged.
Optional: also probe a path whose relationship resolves to nothing (an empty to-one or to-many), so the rule tests the empty-array case and not only a response where included has members anyway.
Done when
The kit has the rule, with a fixture that fails it without the key and passes it with included: [].
A note for the rule's fixtures and the optional empty-relationship probe: #266 (a follow-up to #257) handles the related to-one with empty linkage. ResourceHandlers.related used to return { data: null } before reaching Assemble, so GET …/<to-one>?include=x had no included key, and its include paths were never validated. It now answers { data: null, included: [], jsonapi } when the request carries include, and it rejects an unsupported path with 400.
#266 also makes presence the signal: a bare ?include= (decoded []) gets included: [] from Assemble.* and Handlers.resolveIncluded. A probe that sends an empty include should therefore expect the key.
Activity
thomasfosterau commentedon Oct 8, 2026
A note for the rule's fixtures and the optional empty-relationship probe: #266 (a follow-up to #257) handles the related to-one with empty linkage.
ResourceHandlers.relatedused to return{ data: null }before reachingAssemble, soGET …/<to-one>?include=xhad noincludedkey, and its include paths were never validated. It now answers{ data: null, included: [], jsonapi }when the request carriesinclude, and it rejects an unsupported path with400.#266 also makes presence the signal: a bare
?include=(decoded[]) getsincluded: []fromAssemble.*andHandlers.resolveIncluded. A probe that sends an emptyincludeshould therefore expect the key.Generated by Claude Code
feat(Conformance): require an `included` key in answers to `include`
feat(Conformance): require an `included` key in answers to `include`