Skip to content

fix(validation): validate ontology prefix IRIs - #755

Merged
jbonofre merged 2 commits into
apache:mainfrom
RyutoYoda:fix/ontology-prefix-iri-validation
Nov 18, 2026
Merged

jbonofre merged 2 commits into
apache:mainfrom
RyutoYoda:fix/ontology-prefix-iri-validation

Conversation

@RyutoYoda

@RyutoYoda RyutoYoda commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The ontology schema declares each prefixes value with format: iri, but the Python validator does not enable an IRI format checker. As a result, an invalid namespace value such as not a valid iri at all !!! currently passes validation.

This follow-up is related to #479, which added preservation of iri and prefixes through converter round-trips, and the gap identified in the review of #489. It is complementary to the ontology reference checks in #488; those issues are already closed, so this PR does not claim to close them.

The validator now requires each namespace value to have an absolute IRI scheme and contain no whitespace. The check accepts HTTPS and URN examples without adding a dependency. It intentionally does not implement full RFC 3987 validation.

Reproduction

Input:

version: 0.3.0.dev0
name: InvalidPrefixIri
prefixes:
  foaf: "not a valid iri at all !!!"
ontology:
  - concept: Order
    type: EntityType

Before this change, running:

uv run --no-project validation/validate.py /tmp/ossie-invalid-prefix-iri.yaml --schema ontology/ontology.json

reported Validation PASSED. With this change, the same command exits with status 1 and reports:

[Reference] Prefix 'foaf' has an invalid IRI value

Testing

  • make check — passed on Python 3.13.15 for validator tests (755 passed, 1 skipped), Python SDK (278 passed), spec script tests (15 passed), compliance grader (50 passed), canonical examples, generated spec types, and all 17 compliance fixtures.
  • The single skipped validator test exercises a filename containing invalid UTF-8 bytes; the local filesystem refuses to create that filename. It is unrelated to prefix IRI validation.
  • CLI regression test verifies the invalid prefix fails through the validator's public command path.
  • git diff --check — passed.

Checklist

Validation

  • New validation cases are covered by tests

Tests

  • All existing tests pass locally (make check)
  • New functionality is covered by tests

Compliance

  • No third-party dependencies were added

Specification, ontology definitions, converter behavior, documentation, examples, and contribution-process files are unchanged, so those checklist items do not apply. No new source files were added; no vendored source was copied.

Written with LLM assistance; I reviewed the change, regression tests, and complete diff.

@jbonofre
jbonofre self-requested a review November 18, 2026 21:54
@jbonofre
jbonofre force-pushed the fix/ontology-prefix-iri-validation branch from ba02699 to 840f8ed Compare November 18, 2026 22:00

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for addressing this!

The check in validate_ontology cleanly closes the gap where format: iri in ontology/ontology.json isn't enforced by Draft202012Validator by default, while keeping the validator dependency-free, tolerating malformed shapes on direct calls, and keeping [Schema] vs [Reference] error boundaries intact. Unit and CLI regression tests look solid as well.

I rebased from main.

@jbonofre
jbonofre merged commit 0f458de into apache:main Nov 18, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants