Skip to content

feat(api): the contract declares each operation's error statuses and headers (#1333) - #1336

Merged
athvin merged 1 commit into
mainfrom
feat/1333-openapi-errors
Nov 28, 2026
Merged

athvin merged 1 commit into
mainfrom
feat/1333-openapi-errors

Conversation

@athvin

@athvin athvin commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Closes #1333

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

er-api-spec derives each operation's error statuses and request/response headers from its handler source (transitively through local helpers); openapi.rs emits them as shared components.responses.Error{n} references and header parameters/headers. The regenerated contracts and schema.d.ts; a note in api-contract/references/launch-readiness.md.

#1333, the follow-up #523 (E13) named before closing: a client generated from the contract could not see Idempotency-Key, Idempotent-Replayed, or any status besides 2XX/default.

Proof

  • errors::tests::statuses_and_headers_follow_local_helpers: a fixture handler's statuses come through a helper (guard → 403), its own body (413) and its Principal (401); 202 is not an error; the request and response headers are found through helpers; an unauthenticated handler has none.
  • the_delivery_contract_declares_its_headers_and_error_statuses: in the public document, ingest takes Idempotency-Key, its 2XX carries Idempotent-Replayed, and 401/402/403/404/409/413/422 each reference a shared response whose body requires detail; /healthz has no 401.
  • Contract size: public 554 KB → 637 KB with shared responses (inline was 1,009 KB).
  • make check exit 0; make frontend green (vitest 1139, Playwright 1113).

Risk & rollback

Additive to the contract: new responses and an optional header parameter; no request or success shape changes. git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on brians-MacBook-Pro · 2026-11-28T05:25:09Z

  • main is green with this change on it — the merge SHA, and the run
    that proves it. A later head SHA with this commit as an ancestor counts;
    a cancelled run with zero jobs does not: — b4d5b3d, rust 46093104097 + frontend 46093103992 success
  • images built, or correctly never ran because nothing that goes into
    an image changed: — success, run 46093104013
  • deploy converged — proved by a line the running process emitted, not
    by the image digest and not by the workflow conclusion: — run 46093433872 success; the live process serves the new contract: https://dupezero.com/api/openapi has 13 shared components.responses (none before)
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change: — infra, devcontainer, marketing preview all success on b4d5b3d
  • the board card reached Done through the automation rather than by
    hand, and the issue closed: — OpenAPI declares request/response headers and the documented error statuses #1333 CLOSED by feat(api): the contract declares each operation's error statuses and headers (#1333) #1336 via automation
  • follow-ups are open for everything deferred here — numbers: — none
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: — inline error bodies nearly doubled the contract; shared components.responses keep it to +15%

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

  • Inline error bodies nearly doubled the contract (+82%); OpenAPI's components.responses exists for exactly this, and brings it to +15%.
  • 401 is the Principal extractor's own rejection, invisible in any handler body; it is derived from the signature instead.

Measurements

Files

🤖 Generated with Claude Code

…headers (#1333)

openapi.public.json declared no header parameters and only 2XX/default
responses, so a generated client could not see the retry contract or a
single documented status. Both are now derived from the handler source.

- er-api-spec operations/errors.rs walks each handler and, transitively,
  the local helpers it calls (guard, upload_scope_any, idempotency_key,
  accepted_response …), collecting the StatusCode constants it constructs
  and the header names it reads or sets. A handler taking Principal
  declares 401. It over-approximates — a helper's every status counts —
  the safe direction for a contract.
- Each error status references one shared components.responses.Error{n}
  with the {detail} body, so the contract states each once (+15% size,
  not +82%); Idempotency-Key is an optional header parameter on
  records/ingest and imports, Idempotent-Replayed a 2XX response header.
- 140 of 142 public operations now declare 401 (the two probes do not);
  ingest declares 401/402/403/404/409/413/422/500/501/503.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

The marketing preview was removed because this PR is closed or merged.

@athvin
athvin merged commit b4d5b3d into main Nov 28, 2026
45 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 28, 2026 01:26 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — 4a1c016c Deployed Nov 28, 2026 by athvin via remove closed PR previews #114
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.

OpenAPI declares request/response headers and the documented error statuses E13 — Public data ingestion and transfer for configurable datasets

2 participants