Skip to content

fix(validation): reject non-JSON values in ontology annotations and add follow-up tests - #772

Open
jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:fix/ontology-annotations-followup
Open

jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:fix/ontology-annotations-followup

Conversation

@jbonofre

Copy link
Copy Markdown
Member

Summary

Follow-up to #146 (Ontology: Add annotations (e.g. for OWL import)):

  1. Enforce JSON-representable values in annotations (validation/validate.py):

    • ontology/ontology.json types Annotations as an open object (additionalProperties: true) and ontology/ontology.md requires values to be valid JSON, so jsonschema alone would still accept PyYAML-parsed date, datetime, time, non-finite floats (.inf, .nan), or non-string mapping keys.
    • Added validate_annotation_data (sharing container traversal via _walk_container_dicts and reusing _non_json_value_errors, mirroring validate_extension_data for nonportable_extensions[].data) and wired it into validate_document.
  2. Add unit tests for ontology annotations (validation/tests/test_ontology.py):

    • Offline full-document validation of examples/foaf_owl_import.yaml via validate_document.
    • Acceptance of arbitrary JSON annotations at all four sites (root, concept, relationship, and role — note Role.annotations was not exercised by examples/foaf_owl_import.yaml).
    • Rejection of non-object annotations at all four sites.
    • Continued rejection of unknown fields outside annotations (including custom_properties) at all four sites.
    • Rejection of non-JSON values (date, datetime, time, inf, nan) under annotations at all four sites.
  3. Record Ontology: Add annotations (e.g. for OWL import) #146 in docs/spec_changes.md:

Related Issues

Follow-up to #146.

Checklist

Specification

  • Spec changes are included in core-spec/ and follow the existing structure
  • Spec changes have a [DISCUSS] thread on dev@ with a stated end date, and reach lazy consensus (or pass a [VOTE]) before merge
  • Breaking changes to the spec are clearly called out in the summary
  • For a material spec change, docs/spec_changes.md records rationale, compatibility and migration impact, or the PR explains why no entry is needed

Ontology

  • Ontology changes in ontology/ are consistent with spec changes
  • New or modified terms are defined and documented

Converters

Validation

  • Validation rules in validation/ are updated if the spec changed
  • New validation cases are covered by tests

Documentation

  • docs/ is updated to reflect any user-facing changes
  • New features or behaviors are documented with examples where appropriate
  • CONTRIBUTING.md is updated if the contribution process changed

Examples

  • examples/ are added or updated for any new spec constructs

Tests

  • All existing tests pass (pytest / CI green)
  • New functionality is covered by tests

Compliance

  • ASF license headers are present on all new source files
  • New third-party dependencies follow Third-Party Dependencies
  • If third-party source code is vendored/copied (not just declared as a dependency), NOTICE and/or LICENSE have been updated per ASF policy

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