Repository navigation
refactor(api)!: migrate API errors to RFC 7807 ProblemDetail - #149
hamdirahalpartner-del wants to merge 2 commits into
Conversation
Code coverage overviewLanguages: Java Java / code-coverage/jacoco
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved moderate findings affect error contracts, status codes, and instance URIs, with related specification and documentation updates pending.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (4)
What changed in this PR
This PR migrates REST API errors from ErrorResponse to Spring ProblemDetail/RFC 7807 while retaining legacy fields and updating contracts, tests, and documentation.
Changes:
- Refactors centralized exception handling with timestamps and legacy fields.
- Updates controller OpenAPI schemas and error-response tests.
- Documents the new error contract and migration considerations.
| File | Reviewed changes and final review notes |
|---|---|
src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/handler/ApiExceptionHandlerTest.java |
Updates handler tests. nit (2 votes): pass the request through a framework override and assert ProblemDetail.instance. |
src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityTemplateControllerTest.java |
Updates error assertions; no final review comments. |
src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityDynamicMappingControllerTest.java |
Updates problem media-type assertions; no final review comments. |
src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityControllerTest.java |
Updates error assertions; no final review comments. |
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/handler/ApiExceptionHandler.java |
Implements ProblemDetail mappings. moderate (3 votes): inherited framework mappings can omit legacy fields (also at lines 107 and 543). moderate (1 vote): preserve Spring’s supplied status code for HandlerMethodValidationException. moderate (1 vote): strip only a leading uri= prefix when constructing the instance URI. |
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/InboundWebhookConfigurationController.java |
Updates ProblemDetail OpenAPI schemas; no final review comments. |
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityTemplateController.java |
Updates response annotations. nit (3 votes): regenerate docs/src/static/swagger.yaml so the published specification matches the generated contract. |
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityGraphController.java |
Updates ProblemDetail OpenAPI schemas; no final review comments. |
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityDynamicMappingController.java |
Updates ProblemDetail OpenAPI schemas; no final review comments. |
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityController.java |
Updates ProblemDetail OpenAPI schemas; no final review comments. |
src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/AuditController.java |
Updates ProblemDetail OpenAPI schemas; no final review comments. |
docs/src/contributing/code/exception-handling.md |
Documents the new error contract. nit (1 vote): update the architecture diagram’s stale ErrorResponse reference. nit (2 votes): address the breaking media-type change in the PR title or justify its classification. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e012ca6 to
3896ffd
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical and moderate issues remain in exception handling and the published OpenAPI contract.
9 open findings
Return ProblemDetail for generic API failures · New Advertise application/problem+json in response annotations · New Document ProblemDetail extensions at the schema root · New Remove CI-only localhost token URL from Swagger · New Delegate unreadable-body handling to native ProblemDetail support · New Include instance in domain error responses · New Fix punctuation and spacing in error-format documentation · New Regenerate OpenAPI spec for ProblemDetail responses Mark breaking error media type change in the PR title
2 resolved since last review
🧠 Review effort: Lite
6d3c0a7 to
ff5e520
Compare
7711211 to
2820676
Compare
4909f3b to
1a2a7ab
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Approval is blocked by two moderate API contract inconsistencies in security-filter and webhook error responses, plus a documentation example that omits the documented timestamp field.
3 open issues
7 resolved since last review
Migrate Camel webhook errors or narrow migration scope Add ProblemDetail content to inbound webhook errors Scope migration claim to MVC or migrate webhook errors Migrate principal endpoint security errors to ProblemDetail Remove obsolete ErrorResponse schema from API contract Update contributor docs from ErrorResponse to ProblemDetail Mark breaking error media type change in the PR title
Review effort: Lite
There was a problem hiding this comment.
🟡 Changes recommended
Active documentation, OpenAPI, and exception-handling issues remain unresolved, including a moderate regression that drops parameter and value details from generic validation errors.
5 open issues
Preserve parameter details for non-page/size type mismatches · New Update security filters to emit ProblemDetail responses Document ProblemDetail bodies for audit 401/403 responses · New Document ProblemDetail bodies for EntityController 401/403 responses · New Add timestamp to the ProblemDetail response example
1 resolved since last review
Review effort: Lite
6bed92b to
fee99a4
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Several critical and moderate issues remain, including broken sort validation and persistence consistency, incorrect Swagger HTTP-method documentation, omitted endpoint sorting, and unsafe authentication and CORS defaults.
11 open issues
Sort validation conflicts with the persistence parser · New Restrict credentialed localhost CORS to local environments · New Do not default the JWT decoder URI to NONE · New Preserve sorting when constructing the pageable · New Keep sort binding on the entity listing endpoint · New Local JWT authentication has no configured JWKS URI · New Update security filters to emit ProblemDetail responses Documented sort syntax does not match the parser · New Update the sort description to the accepted syntax · New Set the RFC problem detail type to about:blank · New Add timestamp to the ProblemDetail response example
3 resolved since last review
Review effort: Lite
256c904 to
8b578d7
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Active issues remain that can prevent compilation and cause incorrect API behavior, including swapped Swagger methods, broken sort handling, ignored ordering, and hardcoded CORS configuration.
13 open issues
Restore the SortCriteria import to fix compilation · New Keep CORS origins environment-configurable · New Do not default the JWT decoder URI to NONE Restrict credentialed localhost CORS to local environments Sort validation conflicts with the persistence parser Restore the correct Swagger operation keys · New Local JWT authentication has no configured JWKS URI Keep sort binding on the entity listing endpoint Preserve sorting when constructing the pageable Update security filters to emit ProblemDetail responses Update the sort description to the accepted syntax Documented sort syntax does not match the parser Add timestamp to the ProblemDetail response example
1 resolved since last review
Review effort: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
Approval is blocked by active critical contract and sort-format inconsistencies, along with regressions that discard requested sorting in graph pagination and the controller API.
11 open issues
Restore the SortCriteria import to fix compilation Do not default the JWT decoder URI to NONE Sort validation conflicts with the persistence parser Restore the correct Swagger operation keys Local JWT authentication has no configured JWKS URI Keep sort binding on the entity listing endpoint Preserve sorting when constructing the pageable Update security filters to emit ProblemDetail responses Update the sort description to the accepted syntax Documented sort syntax does not match the parser Add timestamp to the ProblemDetail response example
2 resolved since last review
Review effort: Lite
404e141 to
bf4d489
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Approval is blocked by unresolved critical authorization, resource-exhaustion, and entity-creation issues, along with documentation, validation-message, and local-authentication inconsistencies.
9 open issues
Allow the dry-run resource in the read-only policy · New Bound JSLT evaluations that can outlive request timeouts · New Preserve required kind when creating principal entities · New Do not default the JWT decoder URI to NONE Update the sort validation message to describe comma syntax · New Keep GitHub OAuth login enabled for the local profile · New Restore the correct Swagger operation keys Update security filters to emit ProblemDetail responses Restore the removed Docker Compose and database instructions · New
8 resolved since last review
Restore the SortCriteria import to fix compilation Sort validation conflicts with the persistence parser Local JWT authentication has no configured JWKS URI Keep sort binding on the entity listing endpoint Preserve sorting when constructing the pageable Update the sort description to the accepted syntax Documented sort syntax does not match the parser Add timestamp to the ProblemDetail response example
Review effort: Lite
f541c5d to
88bec47
Compare
3b463d5 to
8b5000c
Compare
|
eb68951 to
382d483
Compare
Signed-off-by: hamdirahalpartner-del <hamdi.rahal.partner@decathlon.com>
df6aa23 to
b7372c5
Compare
…-problem-detail-rfc-7807 Signed-off-by: hamdirahalpartner-del <hamdi.rahal.partner@decathlon.com>






PR Description
What this PR Provides
Fixes
Review
The reviewer must double-check these points:
!after the type/scope to identify the breakingchange in the release note and ensure we will release a major version.
How to test
Initial state: application running normally, no specific data setup required.
What and how to test:
GET /api/v1/entity_templates/{identifier}with a non-existent identifier (404), orPOST /api/v1/entity_templateswith an invalid payload (400)../gradlew test --tests "*ApiExceptionHandlerTest*"along with the impacted controller tests (EntityControllerTest,EntityTemplateControllerTest,EntityDynamicMappingControllerTest).docs/src/static/swagger.yaml/ Swagger UI to confirm error responses now reference theProblemDetailschema.Expected results:
ProblemDetailformat:{"type": ..., "title": ..., "status": ..., "detail": ..., "instance": ...}(Content-Typeapplication/problem+json), replacing the previous{"error": ..., "error_description": ...}format.Breaking changes (if any)
Context of the Breaking Change
The API error response format has been migrated from the internal
ErrorResponseclass ({"error": "...", "error_description": "..."}) to Spring's RFC 7807ProblemDetailstandard (application/problem+json), for all errors (400, 404, 409, 500, etc.) across all endpoints.Result of the Breaking Change
Clients consuming the IDP-Core API that parse error bodies on the
error/error_descriptionfields must be updated to read the newProblemDetailformat:type,title,status,detail,instance. TheContent-Typeof error responses changes toapplication/problem+json.