Repository navigation
TRX-1066: fix(core): exclude accept.notAllowed violations on 204 responses - #414
Conversation
A 204 response has no body, so the request Accept header cannot cause a mismatch. Assert that validation.request.accept.notAllowed is excluded for 204 and still reported for 200 (TRX-1066).
The client controls the request Accept header, and a 204 response has no body. Add Rules.Request.ACCEPT_NOT_ALLOWED and exclude it when the response status is 204. Other statuses and rules are still reported (TRX-1066).
|
No actionable comments were generated in the recent review.
|
|
No change needed. This CodeRabbit comment is a review summary with no actionable findings ("No actionable comments were generated", LGTM on all three files, merge risk minimal). Nothing in it asks for a code change, so there is nothing to fix at |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for this narrowly scoped 204-response exclusion, which preserves the existing handling of other response statuses.
No open issues 🎉
What changed in this PR
This pull request adds a narrowly scoped exclusion for validation.request.accept.notAllowed violations on HTTP 204 responses, where no response body exists, while preserving reporting for other response statuses.
Changes:
- Added
Rules.Request.ACCEPT_NOT_ALLOWED. - Added the
falsePositive204exclusion for 204 responses. - Added regression tests for excluded 204 and retained 200 behavior.
| File | Description |
|---|---|
openapi-validation-core/src/test/java/com/getyourguide/openapi/validation/core/exclusions/InternalViolationExclusionsTest.java |
Verifies the 204 exclusion and confirms 200 violations remain reported. |
openapi-validation-core/src/main/java/com/getyourguide/openapi/validation/core/exclusions/InternalViolationExclusions.java |
Excludes Accept-header violations associated with 204 responses. |
openapi-validation-api/src/main/java/com/getyourguide/openapi/validation/api/Rules.java |
Defines the reusable Accept-not-allowed rule constant. |
Review effort: Lite
Why
traveler-aggregator-fintechlogs this violation forPOST /pages/checkout/customer-information/carts/{shoppingCartHash}:The spec defines the 204 response without content. Only the error responses have a media type (
application/problem+json). A client that sends onlyAccept: application/jsoncauses the violation. The client controls the Accept header, and a 204 response has no body. The violation is noise.What changed
falsePositive204inInternalViolationExclusions. It dropsvalidation.request.accept.notAllowedwhen the response status is 204.Rules.Request.ACCEPT_NOT_ALLOWED.Scope
accept.notAllowedfor all other statuses, for example a 200 with a body.Blast Radius
All services that use the library stop logging and counting this one violation for 204 responses. A 204 has no body, so the excluded violations cannot show a content mismatch.
Verification
./gradlew :openapi-validation-core:test: new testwhen204ResponseCodeWithAcceptNotAllowedViolationThenViolationExcludedfails before the fix and passes after it. The 200 case stays reported.submitCustomerInformationspec:Accept: application/jsonwith 204 gave the violation before the fix and gives none after it. With 200, the violation stays.