fix(serializer): clarify nested-document error with actionable hints#8238
Closed
soyuka wants to merge 1 commit into
Closed
fix(serializer): clarify nested-document error with actionable hints#8238soyuka wants to merge 1 commit into
soyuka wants to merge 1 commit into
Conversation
The previous "Use IRIs instead." hint only told users one of two possible remedies. When a developer intends nested embedding, the real fix is to add matching denormalization groups on the related resource (and, for to-many relations, adder/remover methods on the parent), not to switch to IRIs. Expand the message to surface both options so the failure mode is self-diagnosing. Fixes api-platform#8077
Member
Author
|
Closing per maintainer feedback: the existing error message is sufficient and users can look up the remedy online. Closing the underlying issue with usage guidance instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The denormalizer error "Nested documents for attribute X are not allowed. Use IRIs instead." only mentioned one of two possible remedies. When a developer intends nested embedding, switching to IRIs is the wrong fix — the right one is to add matching denormalization groups (and, for to-many relations, adder/remover methods on the parent class).
Updated the exception message to surface both options so the failure is self-diagnosing.
Reproduction
POST a parent resource with a nested OneToMany collection without
@ids and withoutaddX/removeXaccessors on the parent. The old message wrongly nudged users toward IRIs.Test plan
testInnerDocumentNotAllowedinAbstractItemNormalizerTestto assert the new message.testNestedRelationDocumentReturns400Problemintests/Functional/Hal/ProblemTest.Fixes #8077