Skip to content

feat(Negotiation): check ext URIs, and let a parameterised alternate win (#566) - #572

Merged
thomasfosterau merged 1 commit into
trunkfrom
issue-566-negotiation-extensions
Nov 7, 2026
Merged

thomasfosterau merged 1 commit into
trunkfrom
issue-566-negotiation-extensions

Conversation

@thomasfosterau

Copy link
Copy Markdown
Owner

Summary

Closes #566 (item O4 of gardeneria#1263, tracked in #570).

  • (a) Negotiation.Options.extensions (additive). It lists the extension URIs the api supports, as Middleware's extensions option does. When it is given, a JSON:API instance whose ext names an unlisted URI is not clean: a read with no clean instance left is 406 (NOT_ACCEPTABLE), and a write is 415 (UNSUPPORTED_MEDIA_TYPE), per JSON:API §5. When it is omitted, nothing changes (no ext URI is checked), so a host that already negotiates Atomic through Negotiation doesn't start answering 415. The check is Middleware's own: parametersAreAcceptable moved to src/internal/media.ts, and both modules import it from there.
  • (b) Fix: the §5 parameter rule applies only to JSON:API instances. Before, every Accept entry with a parameter other than ext/profile counted as unclean, so text/markdown;charset=utf-8 could never win its alternate's path and fell back to HTML.
  • (c) The verdict gains no markdown flag. Verdict.representation already names the winning alternate ("text/markdown"), as Negotiation.make: no extensions option, and a parameterised alternate never wins (gardeneria#1263 O4) #566 explains.

Verification

  • pnpm install --frozen-lockfile: pass
  • vp run build: pass
  • vp check: pass. Per-rule lint counts on the four changed files are identical to trunk.
  • vp run check: pass
  • vp run -r test:unit: pass, including the new extensions (#566) block and the parameterised-alternate case
  • vp run docgen: pass
  • vp run test:coverage, then fallow audit --base origin/trunk: pass

Changeset

  • .changeset/negotiation-extensions.md, minor (a new option, plus the alternate fix)

Notes

  • Spec-compliance: with extensions set, Negotiation agrees with Middleware's §5 check on the same header.
  • The new option carries the same prefer-option-over-null disable comment as its sibling onExplicitRefusal: AGENTS.md requires the ?: T | undefined spelling.

Generated by Claude Code

@thomasfosterau
thomasfosterau merged commit 23afecc into trunk Nov 7, 2026
3 checks passed
@thomasfosterau
thomasfosterau deleted the issue-566-negotiation-extensions branch November 7, 2026 08:22
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.

Negotiation.make: no extensions option, and a parameterised alternate never wins (gardeneria#1263 O4)

2 participants