← 输入框|github.com|刷新
Skip to content

TRX-1066: fix(core): exclude accept.notAllowed violations on 204 responses - #414

Merged
pboos merged 2 commits into
mainfrom
TRX-1066-ignore-204-response-wrong-accept-request-header
Nov 2, 2026
Merged

pboos merged 2 commits into
mainfrom
TRX-1066-ignore-204-response-wrong-accept-request-header

Conversation

@pboos

@pboos pboos commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Why

traveler-aggregator-fintech logs this violation for POST /pages/checkout/customer-information/carts/{shoppingCartHash}:

OpenAPI spec validation error [validation.request.accept.notAllowed]
POST https://travelers-api.getyourguide.com/pages/checkout/customer-information/carts/{shoppingCartHash}
Response Status Code: 204

INFO - Request Accept header '[application/json]' does not match any defined response types. Must be one of: [application/problem+json].: []

The spec defines the 204 response without content. Only the error responses have a media type (application/problem+json). A client that sends only Accept: application/json causes the violation. The client controls the Accept header, and a 204 response has no body. The violation is noise.

What changed

  • New built-in exclusion falsePositive204 in InternalViolationExclusions. It drops validation.request.accept.notAllowed when the response status is 204.
  • New constant Rules.Request.ACCEPT_NOT_ALLOWED.

Scope

  • Only this rule, and only for status 204.
  • The library still reports accept.notAllowed for 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 test when204ResponseCodeWithAcceptNotAllowedViolationThenViolationExcluded fails before the fix and passes after it. The 200 case stays reported.
  • End to end with the real validator and a copy of the submitCustomerInformation spec: Accept: application/json with 204 gave the violation before the fix and gives none after it. With 200, the violation stays.

pboos added 2 commits November 2, 2026 09:53
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).
@gyg-pr-tool gyg-pr-tool Bot changed the title fix(core): exclude accept.notAllowed violations on 204 responses TRX-1066: fix(core): exclude accept.notAllowed violations on 204 responses Nov 2, 2026
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central TS config (base), Organization UI (inherited); Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a62fb25a-5b4e-4bd0-9627-27d2ea21f023
Commits

Reviewing files that changed from the base of the PR and between 6d8c3c7 and cc43422.

Files selected for processing: 3
  • openapi-validation-api/src/main/java/com/getyourguide/openapi/validation/api/Rules.java
  • openapi-validation-core/src/main/java/com/getyourguide/openapi/validation/core/exclusions/InternalViolationExclusions.java
  • openapi-validation-core/src/test/java/com/getyourguide/openapi/validation/core/exclusions/InternalViolationExclusionsTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details
Additional comments: 3
openapi-validation-api/src/main/java/com/getyourguide/openapi/validation/api/Rules.java: 1

8-8: LGTM!

openapi-validation-core/src/main/java/com/getyourguide/openapi/validation/core/exclusions/InternalViolationExclusions.java: 1

15-16: LGTM!

Also applies to: 35-38

openapi-validation-core/src/test/java/com/getyourguide/openapi/validation/core/exclusions/InternalViolationExclusionsTest.java: 1

32-32: LGTM!

Also applies to: 163-185

Summary

Risk Score: Normal - Addressing the comments needed

The validator now excludes validation.request.accept.notAllowed violations when the response status is 204. It continues to report the same violation for status 200. This change affects violation reporting and does not change response handling, so it is not on a production outage path.

The regression tests cover both statuses. The PR description reports that the core test suite passes.

The exclusion logic now excludes ACCEPT_NOT_ALLOWED request violations when the response status is 204. Tests check that status 200 violations are not excluded and that a separate request violation with status 204 remains non-excluded.

Suggested labels: coderabbit-risk:normal

Change: Bug fix

Merge Risk: Minimal · up to cc434

No actionable risk remains in the reviewed changes; the PR is mergeable with normal checks.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pboos

pboos commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

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 cc43422.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 falsePositive204 exclusion 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

@pboos
pboos marked this pull request as ready for review November 2, 2026 09:05
@pboos
pboos requested a review from a team as a code owner November 2, 2026 09:05
@clue-gyg clue-gyg removed the risk:low label Nov 2, 2026
@gyg-pr-tool
gyg-pr-tool Bot requested a review from dominik-riha November 2, 2026 09:05
@pboos
pboos merged commit 48aac54 into main Nov 2, 2026
7 checks passed
@pboos
pboos deleted the TRX-1066-ignore-204-response-wrong-accept-request-header branch November 2, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants