[Serializer] Fix serialized path for non-scalar values #49525
Merged
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.
This relates to #49494 and #49225. When non-scalar values are normalized, they are normalized twice in the
normalize()
function:and a bit later:
For non-scalar values with a
SerializedPath
annotation this leads to an exception because the serializer is trying to re-populate the path. RunningupdateData()
only once fixes this, but breaks a couple of tests across the components as it changes the order of elements in the serialized string (non-scalar values will be pushed to the end). Other than the string comparisons, nothing seems to break. This was also an issue while reviewing the PR for theSerializedPath
annotation (#43534 (comment)) and got reverted because of the potential BC break.I'm not sure what benefit normalizing twice brings, so I added the test from @HonzaMatosik, changed the behavior in the normalizer and fixed the broken tests. If that's not the preferred solution here, I'd be ok with just eleminating the "The element you are trying to set is already populated" exception in the
SerializedPath
and allow overwriting values.