Skip to content

Pin the problem+json error/negotiation contract#52

Merged
turegjorup merged 3 commits into
developfrom
test/error-contract-problem-json
Jul 8, 2026
Merged

Pin the problem+json error/negotiation contract#52
turegjorup merged 3 commits into
developfrom
test/error-contract-problem-json

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Closes the last untested corner of the error contract: what the API does when a client asks for application/problem+json.

Changes

Two new ErrorContractTest cases (verified against the running 4.3 API):

  • Auth error as problem+jsonGET /api/v2/events (unauthenticated) with Accept: application/problem+json401, content-type: application/problem+json, RFC 7807 fields (title, detail, status, type). The 401 short-circuits before resource negotiation, so it is served in the requested media type.
  • problem+json not acceptable for resource readsGET /api/v2/events/{id} with Accept: application/problem+json406 Not Acceptable (the resources only produce ld+json), and the 406 body is itself a problem+json error.

Why

The regenerated 4.3 spec documents application/problem+json/application/json media types on error responses, but nothing tested whether the API actually serves them. This pins the real behaviour: problem+json is available for errors that precede resource negotiation (401), but is not a resource representation — asking for it on a resource yields 406, not the resource and not a 404. Consumers must read resources as ld+json. Tests only.

Add two ErrorContractTest cases for Accept: application/problem+json:
an unauthenticated request is served as RFC 7807 problem+json (401,
unprefixed title/detail/status/type), while requesting a resource item
in problem+json yields 406 Not Acceptable (the resources only produce
ld+json) with a problem+json error body. Closes the last untested corner
of the error contract and documents that problem+json is not a resource
representation.
@codecov-commenter

codecov-commenter commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.99%. Comparing base (191e1ed) to head (7fa98e3).
⚠️ Report is 11 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop      #52   +/-   ##
==========================================
  Coverage      72.99%   72.99%           
  Complexity       232      232           
==========================================
  Files             29       29           
  Lines            648      648           
==========================================
  Hits             473      473           
  Misses           175      175           
Flag Coverage Δ
unittests 72.99% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@turegjorup turegjorup self-assigned this Jul 8, 2026
@turegjorup turegjorup merged commit e34ba08 into develop Jul 8, 2026
11 checks passed
@turegjorup turegjorup deleted the test/error-contract-problem-json branch July 8, 2026 14:41
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.

2 participants