v2.1.0 JSON-LD context produces wrong or missing RDF triples, Blank Nodes
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with oemetadata/v2/v21/context.json, example.json, and schema.json, then reproduce the expansion with rdflib and PyLD as described. Compare the generated RDF against the issue's namespace, term, class/property, prefix, and datatype findings; done means the v2.1 context and example no longer lose or invalidate the specified triples and regression coverage is added.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description of the issue
When oemetadata/v2/v21/example.json is converted to RDF with oemetadata/v2/v21/context.json, some metadata is silently dropped and several triples use wrong or invalid IRIs.
JSON Schema validation still passes, so none of this is visible without converting to RDF.
Expected: every key in the schema either maps to a well-known predicate with the correct datatype, or is explicitly marked as JSON-only.
Current: the problems below. They are ordered by impact.
1. Wrong namespaces for dct and dcat (regression from v2.0.x)
"dcat": "https://www.w3.org/ns/dcat#",
"dct": "https://purl.org/dc/terms/",
Both namespaces are defined with http://. With https://, every dct:* and dcat:* term (title, description, license, subject, spatial, temporal, keyword, accessURL, …) becomes a different, non-standard IRI.
Standard tools and queries that look for dct:title or dcat:keyword will not find them.
v2/v20/context.json and production still use the correct http:// versions. The change came in with 0d86e74 (#296) and has already been copied to oemetadata/latest/context.json on develop.
2. Keys without a term definition are dropped from the RDF
JSON-LD processors silently drop any key the context does not define. There is no error.
These keys exist in schema.json/example.json but not in context.json:
| Key | Probable cause | What is lost |
|---|---|---|
datasetLicenses |
Renamed from licenses (#296); context not updated |
All dataset license information |
resourceLicenses |
Same | All resource license information |
projectContext |
New in v2.1, no term definition | Project, funding, publisher, contact |
mappingRelation |
Added in #302 without a term definition | Every skos:exactMatch etc. on isAbout / valueReference |
3. "@id": null in the example is rejected by strict processors
example.json contains "@id": null six times (in the empty valueReference entries).
pyld fails the whole document with Invalid JSON-LD syntax; "@id" value must be a string.
Some tools (e.g. rdflib) accept it, so whether the file parses depends on the tool.
4. Classes used as properties
These terms map to an RDF class, but they are used as a property (predicate):
| Key | Mapped to | Suggested property |
|---|---|---|
contributors |
foaf:Agent |
dct:contributor (or prov:qualifiedAttribution, see below) |
resources |
dcat:Dataset |
dcat:distribution (or dct:hasPart) |
resource (foreign key reference) |
dcat:Distribution |
a csvw reference property, e.g. csvw:resource |
timeseries |
dct:PeriodOfTime |
dct:temporal, with @type dct:PeriodOfTime on the object |
A class used as a predicate is valid RDF syntax, but the result has no useful meaning and does not work with DCAT/Dublin Core tooling.
5. Broken ncit prefix
"ncit": "http://purl.obolibrary.org/obo/ncit.owl",
The prefix has no trailing separator, so nullable → ncit:NCIT_C47840 expands to http://purl.obolibrary.org/obo/ncit.owlNCIT_C47840, which is not a valid term IRI.
The correct IRI is http://purl.obolibrary.org/obo/NCIT_C47840. That means prefix http://purl.obolibrary.org/obo/, as already used for IAO.
This prefix is the same in v2.0.
6. Datatypes that don't match the values
| Key | Declared type | Example value |
|---|---|---|
embargoPeriod.start / .end |
xsd:dateTime |
"2024-10-11" (a date) |
sources.publicationYear |
xsd:date |
"2023" (a year → xsd:gYear) |
The resulting literals are ill-typed and are rejected or ignored by validating RDF stores and SHACL.
Steps to Reproduce
pip install rdflib pyld- Merge
oemetadata/v2/v21/example.jsonwith the@contextfromoemetadata/v2/v21/context.json. Replace the example's remote@contextURL, and remove the"@id": nullentries so the document parses at all. - Parse with rdflib (
Graph().parse(data=..., format="json-ld")) and inspect the predicates.
Alternatively paste the merged document into the JSON-LD Playground and look at the N-Quads tab. - You will see:
https://purl.org/dc/terms/…andhttps://www.w3.org/ns/dcat#…predicates;- no license, project context or
mappingRelationtriples; …/ncit.owlNCIT_C47840;- rdflib warnings for the ill-typed date literals.
- Running
pyld.jsonld.expand()on the unmodified merged document fails on"@id": null.
Ideas of solution
-
Namespaces: set
dctanddcatback tohttp://, in bothv21/context.jsonandlatest/context.json. This is a trivial fix with no downside. -
Missing terms: add term definitions for
datasetLicenses,resourceLicenses(e.g.dct:license,@container: @set) andprojectContext(e.g.prov:wasGeneratedBywith a scoped context for its sub-keys).
mappingRelationneeds a modelling decision. Its value (skos:exactMatch) really describes which predicate should connect the column to the concept, and a plain term definition can't express that. The options are:- (a) map it as a plain literal /
@vocabIRI for now; - (b) model the mapping as its own node, e.g. SSSOM-style
subject/predicate/object; - (c) have a generator emit
column skos:exactMatch conceptdirectly.
(a) is quick. (b) or (c) produce usable RDF.
- (a) map it as a plain literal /
-
"@id": null: omit@idin the example/template when there is no value, instead of writingnull. Alternatively, have the template use an empty object and document that keys without a value should be left out. -
Classes as properties: remap to the properties suggested above. For
contributors, usedct:contributorfor now. The proper model separates the contribution (role, date, object; a qualified attribution) from the agent (person, with an IRI such as an ORCID). That could be done in a follow-up. -
ncit: change the prefix tohttp://purl.obolibrary.org/obo/(or mapnullableto the full IRI). Consider backporting to v2.0. -
Datatypes: use
xsd:datefor the embargo period, or change the example to full datetimes. Usexsd:gYearforpublicationYear. -
Prevent regressions: add a test that expands the example with the context and fails when a schema key is neither mapped nor on an explicit "JSON-only" allow-list, when a prefix IRI does not end in
/or#, or when a literal is ill-typed. That test would have caught items 1, 2, 5 and 6.
Out of scope here and worth a separate enhancement issue: many nodes end up as blank nodes (licenses, contributors, sources, columns, …) because they have no @id. This makes them impossible to link across datasets.
Context and Environment
- Version used: v2.1.0 (in development,
develop/feature-298-module-energy-system) - Operating system: Linux (WSL2)
- Environment setup and (python) version: Python 3.10.12, rdflib 7.6.0, PyLD 3.3.0; also checked with the JSON-LD Playground
Workflow checklist
- I am aware of the workflow in CONTRIBUTING.md
- Ngôn ngữ chính
- Python
- Star
- 26
- Fork
- 4
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenEnergyPlatform/oemetadata
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
OpenEnergyPlatform/oemetadata#328 ·
-
Develop AI tooling for usersĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
OpenEnergyPlatform/oemetadata#327 · 1 bình luận ·
-
Codecov workflow fails on every develop push: frictionless not installedCó thể đã có người làm @jh-RLI đã nhận 52 ngày trước. Đang mởpart: github :octocat: status: active 🚧 type: bug 🐛
OpenEnergyPlatform/oemetadata#325 · 1 người được giao ·
-
The "@id" fields cause problems, rename to "id"Có thể đã có người làm @jh-RLI đã nhận 52 ngày trước. Đang mởpart: backend 🧱 part: documentation 📖 priority: critical 🔥 status: active 🚧 type: enhancement ⚙️
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
OpenEnergyPlatform/oemetadata#320 · 10 bình luận · 2 người được giao ·
-
Revise and update testsCó thể đã có người làm @jh-RLI đã nhận 52 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
OpenEnergyPlatform/oemetadata#316 · 1 bình luận · 3 người được giao ·
Tất cả issue của OpenEnergyPlatform/oemetadata
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Harden tools/pr_threads.sh: pass all printed thread fields through the deterministic sanitizerĐang mởarea:cli area:security enhancement priority:medium size:small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
RonaldHensbergen/composable-data-stack#1338 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:stdlib effort:S impact:med platform:linux type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
automated endpoint-dead needs-curation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
almanac-data/climate-almanac#139 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày