fix(repository): re-escape reserved words on the read-merge-write upd… - #168
Merged
Merged
Conversation
…ate path
The replaceOnUpdate path (needed for Scorpio 6.x, which appends instead of
replacing on POST /entities/{id}/attrs) reads the existing entity back from the
broker and writes it out again via batch upsert. That read goes through the
EscapeCleaningParser of the mapping library, which strips the `tmfEscaped-`
prefix from every reserved word it can safely unescape - i.e. all of them except
the VO field collisions `id`, `type` and `value`. Nothing put the prefix back
before the entity was written, so raw JSON-LD keywords ended up on the wire.
Scorpio >= 6.0.0 drops `@id`/`@type`/`@value`/`@context` inside Property values,
so any free-form value carrying expanded JSON-LD was silently mangled on the
first update. Concretely: the ODRL policy of a product-offering-price lost its
`@type`/`@id`, which made the EDC fail to map the offer and left contract
negotiations hanging in REQUESTED.
Re-apply the escape recursively (property values, sub-attributes and
multi-attributes) before the merged entity goes out. escapeReservedWords is
idempotent, so keys that kept their prefix during parsing are untouched.
Also guard the merge against an update without additional properties, which
used to NPE.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Mortega5
approved these changes
Aug 5, 2026
wistefan
approved these changes
Aug 6, 2026
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.
…ate path
The replaceOnUpdate path (needed for Scorpio 6.x, which appends instead of replacing on POST /entities/{id}/attrs) reads the existing entity back from the broker and writes it out again via batch upsert. That read goes through the EscapeCleaningParser of the mapping library, which strips the
tmfEscaped-prefix from every reserved word it can safely unescape - i.e. all of them except the VO field collisionsid,typeandvalue. Nothing put the prefix back before the entity was written, so raw JSON-LD keywords ended up on the wire.Scorpio >= 6.0.0 drops
@id/@type/@value/@contextinside Property values, so any free-form value carrying expanded JSON-LD was silently mangled on the first update. Concretely: the ODRL policy of a product-offering-price lost its@type/@id, which made the EDC fail to map the offer and left contract negotiations hanging in REQUESTED.Re-apply the escape recursively (property values, sub-attributes and multi-attributes) before the merged entity goes out. escapeReservedWords is idempotent, so keys that kept their prefix during parsing are untouched.
Also guard the merge against an update without additional properties, which used to NPE.