Skip to content

fix(api): return 400 for invalid graph traversal modes - #169

Merged
foukou19 merged 1 commit into
mainfrom
CPDE-3321-idp-core-error-response-when-uknow-graph-mode
Oct 22, 2026
Merged

foukou19 merged 1 commit into
mainfrom
CPDE-3321-idp-core-error-response-when-uknow-graph-mode

Conversation

@hamdirahalpartner-del

@hamdirahalpartner-del hamdirahalpartner-del commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Return HTTP 400 Bad Request instead of 500 for request parameter type mismatches.
  • Include the invalid parameter name and value in the error description.
  • List allowed enum values when an unsupported value is provided.
  • Preserve supported traversal modes and the default DIRECT_LINEAGE mode.
  • Document the graph endpoint's 400 response in OpenAPI annotations and the static Swagger specification.
  • Add regression tests for invalid parameters and supported traversal modes.

Fixes

Review

The reviewer must double-check these points:

  • The reviewer has tested the fix
  • The reviewer has reviewed the implementation
  • The documentation has been updated

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:

GET /api/v1/entities/{templateIdentifier}/{entityIdentifier}/graph?traversal_mode=OUTBOUND_ONL

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, and OUTBOUND_ONLY.

Expected result: HTTP 200 OK with the entity graph.

Call the endpoint without the traversal_mode parameter.

Expected result: HTTP 200 OK, using DIRECT_LINEAGE as the default.

Other invalid parameter types

Call the endpoint with depth=abc or include_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 ErrorResponse schema.

Breaking changes (if any)

  • N/A. Valid requests and response schemas remain unchanged. Invalid parameter values now return HTTP 400 instead of HTTP 500.

Context of the Breaking Change

N/A.

Result of the Breaking Change

N/A.

@hamdirahalpartner-del
hamdirahalpartner-del requested review from brandPittCode and a balanced review from Copilot October 16, 2026 07:09
@CLAassistant

CLAassistant commented Oct 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@github-code-quality

github-code-quality Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Java

Java / code-coverage/jacoco

main 1e7741b CPDE-3321-idp-core-e... c2cd89f +/-
91% 91% 0%
View coverage of the 3 most impacted files.
File main 1e7741b CPDE-3321-idp-core-e... c2cd89f +/-
com/decathlon/i...ationUtils.java 87% 87% 0%
com/decathlon/i...ionHandler.java 83% 84% +1%
com/decathlon/i...oOutMapper.java 95% 97% +2%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 22, 2026 07:10 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused handler change, regression coverage, and API documentation are consistent; no blocking issues were identified, though tests were not executed.

1 open finding

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No blocking issues were identified in the focused handler, documentation, and regression-test changes; tests were not executed.

1 open issue

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Static review found no blocking issues in the focused implementation, regression coverage, or documentation; tests were not executed.

1 open issue

Review effort: Balanced

foukou19
foukou19 previously approved these changes Oct 21, 2026
@foukou19
foukou19 enabled auto-merge (squash) October 21, 2026 13:01
@hamdirahalpartner-del
hamdirahalpartner-del force-pushed the CPDE-3321-idp-core-error-response-when-uknow-graph-mode branch 2 times, most recently from 0e419c7 to d605169 Compare October 21, 2026 14:55
@hamdirahalpartner-del
hamdirahalpartner-del removed the request for review from brandPittCode October 22, 2026 06:26
Signed-off-by: hamdirahalpartner-del <hamdi.rahal.partner@decathlon.com>
@hamdirahalpartner-del
hamdirahalpartner-del force-pushed the CPDE-3321-idp-core-error-response-when-uknow-graph-mode branch from 8fdc65f to c2cd89f Compare October 22, 2026 07:06
@sonarqubecloud

Copy link
Copy Markdown

@foukou19
foukou19 merged commit 822b98a into main Oct 22, 2026
20 checks passed
@foukou19
foukou19 deleted the CPDE-3321-idp-core-error-response-when-uknow-graph-mode branch October 22, 2026 09:00
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.

5 participants