Skip to content

feat(Conformance): a rule that a response to ?include= carries an included key, even empty #256

Closed

Description

@thomasfosterau

Problem

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.
  • Update the rule table in docs/conformance.md, and the examples' conformance suites if their expected-failure lists change. After bug: compound documents omit included when ?include= resolves to nothing #232 the examples should pass the rule.
  • 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: [].
  • docs/conformance.md lists the rule.
  • The three examples pass it.

Generated by Claude Code

Activity

  1. added
    enhancement
    on Oct 8, 2026
  2. thomasfosterau commented on Oct 8, 2026

    @thomasfosterau
    OwnerAuthor

    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.


    Generated by Claude Code

  3. added 2 commits that reference this issue on Oct 22, 2026
    6479594
    a3de719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions