Skip to content

feat(core): filter out invalid entity identifiers for optional relations - #179

Draft
evebrnd wants to merge 6 commits into
mainfrom
feat/tolerant-webhook-ingestion-optional-relations
Draft

evebrnd wants to merge 6 commits into
mainfrom
feat/tolerant-webhook-ingestion-optional-relations

Conversation

@evebrnd

@evebrnd evebrnd commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

PR Description

What this PR Provides

Apply relation normalization to entity create, update, and patch writes through both the REST API and webhook ingestion.

  • Filters out unknown target identifiers from optional relations : resolved target identifiers are kept for persistence and the relation is omitted if no targets remain.
  • Keeps required relations and target template checks strict, and validates cardinality (to_many) after filtering.

Review

The reviewer must double-check these points:

  • The reviewer has tested the feature
  • The reviewer has reviewed the implementation of the feature
  • The documentation has been updated
  • The feature implementation respects the Technical Doc / ADR previously produced

How to test

Initial state

  • Use a template 1, with an optional relation and an existing target entity identifier. Use another template 2 to check the required relation behavior.

Steps

  1. POST a valid template 1 entity with an existing target entity identifier and a missing identifier.
  2. Repeat through PUT and PATCH, then retrieve the entity to inspect its persisted relations.
  3. Submit an optional template 1 relation containing only a non existent target.
  4. Submit an unresolved target for template 2 through REST and webhook ingestion. Verify failure. Also verify a found target with an incompatible template fails validation.

Expected results

  • POST, PUT, and PATCH succeed when some optional targets are unresolved : resolved targets remain for persistance and unresolved identifiers are omitted. If none resolve, the optional relation is omitted.
  • Required-relation failures return HTTP 400 from REST and HTTP 422 from webhook ingestion. Existing targets with incompatible templates fail validation.
  • Cardinality is checked against the targets remaining after unresolved optional targets are filtered.

Breaking changes

  • Behavior modification: REST entity writes now accept unresolved optional relation targets instead of rejecting the whole write. These unknown optional relation targets are simply removed before persistence.
  • API schema: No JSON schema change.

Result of the Breaking Change

REST clients that previously received HTTP 400 solely because an optional target was unresolved will now receive a successful write response, with the unresolved identifier omitted from persistence. Updates and patches can remove dangling optional links; valid relations and properties are preserved. Required relation failures remain HTTP 400 for REST and HTTP 422 for webhooks.

@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Java

Java / code-coverage/jacoco

main fd49b18 feat/tolerant-webhoo... 9878c2c +/-
91% 91% 0%
View coverage of the 5 most impacted files.
File main fd49b18 feat/tolerant-webhoo... 9878c2c +/-
com/decathlon/i...ionService.java 100% 99% -1%
com/decathlon/i...ationUtils.java 87% 87% 0%
com/decathlon/i...dationMode.java 0% 100% +100%
com/decathlon/i...figuration.java 0% 100% +100%
com/decathlon/i...Properties.java 0% 100% +100%

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


Updated October 30, 2026 16:35 UTC

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

1 participant