Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adds checks on prefixes post JSON-LD expansion process #4235

Merged
merged 2 commits into from
Jun 5, 2024

Conversation

wolf4ood
Copy link
Contributor

@wolf4ood wolf4ood commented Jun 4, 2024

What this PR changes/adds

A new JSON-LD validator has been introduced in order to walk the input JsonObject after the expansion process
and check if some property name or @id/@type values still contains prefixed notation and checks those prefixes against the configured ones for the runtime.
This can happen on custom properties (that we have in almost all entities) when the input JSON-LD object does not contains the prefix alias in the @context.

For example like in the #4160 issue if a user post a property dct:type without explicitly mapping dct in the context :

{
    "@context": {
        "dct": "http://purl.org/dc/terms/"
    },
    "dct:type": "mytype"
}

It will cause the property to be stored as dct:type instead of the expanded form. This is not always an issue but it can lead to JsonLD error in compaction as Absolute IRI confused with prefix.

Since there are multiple places where we support custom properties in our entities, almost in every entities
the prefix check is added directly after the expansion process in the default JSON-LD service implementation.

The prefixes checker can be disabled with the setting edc.jsonld.prefixes.check, but it's activated by default

Why it does that

Fixes eventual compaction issue when returning JSON-LD objects

Further notes

Linked Issue(s)

Closes #4160

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

@wolf4ood wolf4ood added the bug Something isn't working label Jun 4, 2024
@wolf4ood wolf4ood self-assigned this Jun 4, 2024
@wolf4ood wolf4ood force-pushed the fix/4160_jsonld_compaction branch 2 times, most recently from 05dd75a to 3e231d9 Compare June 4, 2024 17:09
@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2024

Codecov Report

Attention: Patch coverage is 87.95181% with 10 lines in your changes missing coverage. Please review.

Project coverage is 75.40%. Comparing base (7f20ba5) to head (7469757).
Report is 288 commits behind head on main.

Files Patch % Lines
...lidator/jsonobject/validators/MissingPrefixes.java 83.05% 6 Missing and 4 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4235      +/-   ##
==========================================
+ Coverage   71.74%   75.40%   +3.65%     
==========================================
  Files         919     1036     +117     
  Lines       18457    20683    +2226     
  Branches     1037     1156     +119     
==========================================
+ Hits        13242    15595    +2353     
+ Misses       4756     4575     -181     
- Partials      459      513      +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wolf4ood wolf4ood force-pushed the fix/4160_jsonld_compaction branch 5 times, most recently from 35229e3 to bbd2e13 Compare June 5, 2024 09:44
@wolf4ood wolf4ood marked this pull request as ready for review June 5, 2024 10:01
@wolf4ood wolf4ood force-pushed the fix/4160_jsonld_compaction branch from acb5120 to 7469757 Compare June 5, 2024 14:16
@wolf4ood wolf4ood merged commit fc10475 into eclipse-edc:main Jun 5, 2024
16 checks passed
@wolf4ood wolf4ood deleted the fix/4160_jsonld_compaction branch June 5, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON-LD compaction error on catalog-request
5 participants