Skip to content

feat: Surface oneOf/anyOf validation failures in an RFC 9457 errors[] array#104

Merged
thced merged 13 commits into
masterfrom
feat/oneof-branch-errors
Jun 8, 2026
Merged

feat: Surface oneOf/anyOf validation failures in an RFC 9457 errors[] array#104
thced merged 13 commits into
masterfrom
feat/oneof-branch-errors

Conversation

@thced

@thced thced commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Validation application/problem+json responses now carry an errors[] array (RFC 9457). pointer and keyword move from the top level into one entry per failure: { "pointer": "#/…", "keyword": …, "detail": … }.
  • oneOf / anyOf failures now surface each failed branch's real error instead of only the opaque matched 0 of N … branches count. Entries are ordered most-likely-cause first (the branch the payload most resembles — deepest pointer) and exact duplicates are collapsed. The top-level detail keeps the combinator summary.
  • Pointers use the RFC 9457 #/… JSON-Pointer-in-fragment form (# for the whole body).
  • instance is intentionally not added (optional under RFC 9457; the default ExceptionHandler has no request context by design).
  • README "Error responses" section updated to RFC 9457 with the new shape and examples.

Before

{ "type": "about:blank", "title": "Bad Request", "status": 400,
  "detail": "matched 0 of 2 oneOf branches", "pointer": "/offers/0", "keyword": "oneOf" }

After

{ "type": "about:blank", "title": "Bad Request", "status": 400,
  "detail": "matched 0 of 2 oneOf branches",
  "errors": [
    { "pointer": "#/offers/0/conditions/0/itemSet/minQuantity", "keyword": "type", "detail": "expected number" }
  ] }

Test plan

  • mvn verify green: 522 unit tests + 68 integration tests, 0 failures.
  • New unit coverage pins deepest-first ordering, exact de-duplication, equal-depth stable order, nested-combinator single-entry flattening, #/… fragment form, empty-array and null-keyword omission, and the no-throw happy-path contract.
  • OpenApiServerIT /shapes asserts the new array end-to-end: a distinct-leaf body yields two entries; an identical-leaf body de-duplicates to one.

Design: docs/superpowers/specs/2026-06-08-validation-errors-array-design.md

@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@thced thced merged commit f4d64fc into master Jun 8, 2026
6 checks passed
@thced thced deleted the feat/oneof-branch-errors branch June 8, 2026 17:58
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.

1 participant