Skip to content

fix(repository): re-escape reserved words on the read-merge-write upd… - #168

Merged
vramperez merged 1 commit into
mainfrom
fix/reescape-reserved-words-on-replace
Aug 6, 2026
Merged

fix(repository): re-escape reserved words on the read-merge-write upd…#168
vramperez merged 1 commit into
mainfrom
fix/reescape-reserved-words-on-replace

Conversation

@vramperez

Copy link
Copy Markdown
Collaborator

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

…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>
@vramperez
vramperez requested a review from Mortega5 August 5, 2026 12:57
@vramperez vramperez added the minor Bigger fixes, added functionality, NO breaking changes label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The following api specs are unavailable, please check if there are updates required.

Module Url
account https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF666_Account_Management_API_v4.0.0_swagger.json
agreement https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF651_Agreement_Management_API_v4.0.0_swagger.json
customer-bill-management https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF678_Customer_Bill_Management_API_v4.0.0_swagger.json
customer-management https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF629_Customer_Management_API_v4.0.0_swagger.json
party-catalog https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF632_Party_Management_API_v4.0.0_swagger.json
party-role https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF669_Party_Role_Management_API_v4.0.0_swagger.json
product-catalog https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.1.0/swagger/TMF620_Product_Catalog_Management_API_v4.1.0_swagger.json
product-inventory https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF637_Product_Inventory_Management_API_v4.0.0_swagger.json
product-ordering-management https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF622_Product_Ordering_Management_API_v4.0.0_swagger.json
resource-catalog https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.1.0/swagger/TMF634_Resource_Catalog_Management_API_v4.1.0_swagger.json
resource-function-activation https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF664_Resource_Function_Activation_Management_API_v4.0.0_swagger.json
resource-inventory https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF639_Resource_Inventory_Management_API_v4.0.0_swagger.json
service-catalog https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF633_Service_Catalog_Management_API_v4.0.0_swagger.json
usage-management https://tmf-open-api-table-documents.s3.eu-west-1.amazonaws.com/OpenApiTable/4.0.0/swagger/TMF635_Usage_Management_API_v4.0.0_swagger.json

@vramperez
vramperez requested a review from wistefan August 6, 2026 09:54
@vramperez
vramperez merged commit 9e4baef into main Aug 6, 2026
83 of 148 checks passed
@vramperez
vramperez deleted the fix/reescape-reserved-words-on-replace branch August 6, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Bigger fixes, added functionality, NO breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants