fix: adds checks on prefixes post JSON-LD expansion process #4235
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.
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 mappingdct
in the context :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 asAbsolute 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 defaultWhy 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.