Skip to content

fix(validation): treat an absent @context as every property unmapped - #142

Merged
simontaurus merged 1 commit into
mainfrom
fix/empty-context-unmapped
Aug 29, 2026
Merged

fix(validation): treat an absent @context as every property unmapped#142
simontaurus merged 1 commit into
mainfrom
fix/empty-context-unmapped

Conversation

@simontaurus

Copy link
Copy Markdown
Contributor

Fixes #141.

Before

FAIL roundtrip.generated    N.schema.json: property lost through RDF despite being mapped: v
6 ok, 1 failed, 0 warning(s), 1 skipped

v is not mapped; the schema declares no @context. OOLD-SCH-2d05 says an unmapped term must not be a conformance failure.

After

WARN OOLD-SCH-21d7 context.coverage   N.schema.json: schema declares no @context, so none of its 1 property
                                      will reach RDF: v. Declare @vocab to map them into a default
                                      namespace, or add the terms to x-oold-context.
7 ok, 0 failed, 1 warning(s), 1 skipped

Change

_unmapped_properties split the two cases its docstring already distinguished. A context that cannot be resolved still returns the empty set, because the checks that report resolution failures own that. A context that resolves to nothing is the opposite: no term exists, so every declared property is unmapped.

context.coverage also reports the empty-context case, which it skipped past. Without that, a schema with no @context produced no signal at all once the wrong failure was removed - quieter than a schema that maps nine properties out of ten.

Verification

  • pytest: 560 passed, 9 skipped, plus a no_context.schema.json fixture and a regression test
  • oold-schema/examples 380 ok / 0 failed and examples/compliance 72 ok / 0 failed, both unchanged
  • parity against validate.mjs: 6 passed

Parity failed on main before this branch, for an unrelated reason: the remote meta cache still held a copy of refs/heads/main from before OO-LD/oold-schema#152, so coverage.vocab demanded a fixture for a keyword that no longer exists. oold meta fetch --force clears it. That is #138, noted there.

_unmapped_properties returned the empty set for a context that resolved
to nothing, so roundtrip.generated counted every declared property as a
mapped loss and failed the schema for what OOLD-SCH-2d05 permits.

context.coverage now reports the case it was silent on, so a schema
mapping none of its properties is not quieter than one mapping all but
one.

Closes #141
@github-actions

Copy link
Copy Markdown
Contributor

Release preview

Merging this PR would release v0.18.2 (current: v0.18.1).

Changelog preview (truncated)
## v0.18.2 (2026-08-29)

### Bug Fixes

- **validation**: Treat an absent @context as every property unmapped
  ([`25cdbf5`](https://github.com/OO-LD/oold-python/commit/25cdbf5ddf074359ed4c1110d83b782761cb6aa1))

Preview via python-semantic-release and conventional commits.

@github-actions

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Click to see benchmark comparison
📊 Benchmark Comparison (threshold: 1.3x)
============================================================

➖ Unchanged (within threshold):
  ➖ test_simple_dict_document_store: 0.0012s → 0.0012s (-0.2%)
  ➖ test_sqlite_document_store: 0.0013s → 0.0013s (-1.4%)
  ➖ test_local_sparql_store: 0.0299s → 0.0298s (-0.4%)
  ➖ test_oneof_subschema: 0.0478s → 0.0474s (-0.9%)
  ➖ test_enum_docstrings: 0.0429s → 0.0404s (-5.7%)
  ➖ test_subclass_inheritance: 0.0480s → 0.0428s (-10.7%)
  ➖ test_class_hierarchy: 0.0461s → 0.0422s (-8.5%)
  ➖ test_core[v1]: 0.0336s → 0.0305s (-9.1%)
  ➖ test_core[v2]: 0.0410s → 0.0352s (-14.2%)
  ➖ test_schema_generation[v1]: 0.0012s → 0.0012s (-0.6%)
  ➖ test_schema_generation[v2]: 0.0020s → 0.0020s (-0.4%)
  ➖ test_simple_json: 0.0004s → 0.0004s (-0.5%)
  ➖ test_complex_graph: 0.0011s → 0.0011s (-2.6%)

============================================================
Summary: 0 regressions, 0 improvements, 13 unchanged
============================================================

✅ No significant performance regressions

Threshold: 1.3x (30% slower triggers a regression warning)

Note: Benchmarks are informational only and won't fail the build.

💡 Tip: Download the benchmark-results artifact for detailed JSON data

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@simontaurus
simontaurus merged commit bc6e1c9 into main Aug 29, 2026
21 checks passed
@simontaurus
simontaurus deleted the fix/empty-context-unmapped branch August 29, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roundtrip.generated fails a schema that declares no @context

1 participant