Repository navigation
fix(api): return 400 for invalid graph traversal modes - #169
hamdirahalpartner-del wants to merge 3 commits into
Conversation
Handle request parameter type mismatches with descriptive error messages and list allowed enum values instead of returning 500. Document the graph endpoint's 400 response and add regression tests. Signed-off-by: hamdirahalpartner-del <hamdi.rahal.partner@decathlon.com>
|
|
There was a problem hiding this comment.
🟡 Changes recommended
The published static OpenAPI contract still needs regeneration to include the new 400 response.
1 open finding
What changed in this PR
Improves API error handling so invalid graph parameters return descriptive 400 responses instead of 500 errors.
Changes:
- Adds type-mismatch handling with allowed enum values.
- Documents the graph endpoint’s 400 response.
- Adds regression tests for invalid, supported, and default parameters.
| File | Description |
|---|---|
| src/test/java/com/decathlon/idp_core/infrastructure/adapters/api/handler/ApiExceptionHandlerTest.java | Tests parameter conversion and error responses. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/handler/ApiExceptionHandler.java | Handles parameter type mismatches as 400 errors. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/controller/EntityGraphController.java | Declares the graph endpoint’s 400 response. |
| src/main/java/com/decathlon/idp_core/infrastructure/adapters/api/configuration/SwaggerDescription.java | Adds the invalid-query response description. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @ResponseStatus(OK) | ||
| @Operation(summary = ENDPOINT_GET_ENTITY_GRAPH_FLAT_SUMMARY, description = ENDPOINT_GET_ENTITY_GRAPH_FLAT_DESCRIPTION, responses = { | ||
| @ApiResponse(responseCode = OK_CODE, description = RESPONSE_ENTITY_GRAPH_FLAT_SUCCESS, content = @Content(schema = @Schema(implementation = EntityGraphFlatDtoOut.class))), | ||
| @ApiResponse(responseCode = BAD_REQUEST_CODE, description = RESPONSE_INVALID_GRAPH_QUERY, content = @Content(schema = @Schema(implementation = ErrorResponse.class))), |
Signed-off-by: hamdirahalpartner-del <hamdi.rahal.partner@decathlon.com>
Code coverage overviewLanguages: Java Java / code-coverage/jacoco
View coverage of the 3 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Signed-off-by: hamdirahalpartner-del <hamdi.rahal.partner@decathlon.com>
|




Handle request parameter type mismatches with descriptive error messages and list allowed enum values instead of returning 500.
Document the graph endpoint's 400 response and add regression tests.
PR Description
What this PR Provides
DIRECT_LINEAGEmode.Fixes
Review
The reviewer must double-check these points:
How to test
Initial state
Run the application and authenticate with an account authorized to access the graph endpoint.
Ensure an entity exists and use its template identifier and entity identifier in the requests below.
Invalid traversal mode
Call the endpoint with an unsupported traversal mode:
Expected result: HTTP 400 Bad Request with this response:
{ "error": "BAD_REQUEST", "error_description": "Invalid value 'OUTBOUND_ONL' for parameter 'traversal_mode'. Allowed values: [DIRECT_LINEAGE, BIDIRECTIONAL, OUTBOUND_ONLY]." }Supported traversal modes
Call the endpoint with each supported value:
DIRECT_LINEAGE,BIDIRECTIONAL, andOUTBOUND_ONLY.Expected result: HTTP 200 OK with the entity graph.
Call the endpoint without the
traversal_modeparameter.Expected result: HTTP 200 OK, using
DIRECT_LINEAGEas the default.Other invalid parameter types
Call the endpoint with
depth=abcorinclude_data=invalid.Expected result: HTTP 400 Bad Request with an error description identifying the invalid parameter, its value, and the expected type.
API documentation
Open the documentation site's Swagger UI and inspect the graph endpoint.
Expected result: the endpoint documents the 400 response with the
ErrorResponseschema.Breaking changes (if any)
Context of the Breaking Change
N/A.
Result of the Breaking Change
N/A.