Skip to content

Report unknown properties on 3.0 Manifest and AnnotationPage as warnings - #228

Open
Zwiterrion wants to merge 2 commits into
IIIF:mainfrom
Zwiterrion:v3-extension-properties
Open

Zwiterrion wants to merge 2 commits into
IIIF:mainfrom
Zwiterrion:v3-extension-properties

Conversation

@Zwiterrion

Copy link
Copy Markdown

Hi! I'm working on Adno, an open-source web application for viewing, editing and sharing narratives and guided explorations on IIIF and static images. We are currently making Adno's exports conform to IIIF Presentation 3.0 and the W3C Web Annotation Data Model.

Context

I planned to check Adno's exports in our CI with this validator's GitHub Action. In our new export, an Adno project becomes a IIIF 3 Manifest. The editor's own data (viewer settings, image list) moves out of metadata into a namespaced key at the Manifest root, adno:project, declared by our own context placed before the IIIF context.

I cloned the repository locally and tested a minimal Manifest with that shape. The validator rejects it:

Additional properties are not allowed ('ext:project' was unexpected)

I traced it to additionalProperties: false on the manifest and annotationPage definitions of schema/iiif_3_0.json. As far as I can tell, the specification allows these properties:

  • §3 Resource Properties: "Other properties are allowed, either via local extensions or those endorsed by the IIIF community. If a client discovers properties that it does not understand, then it must ignore them."
  • §4.6 Linked Data Context and Extensions: additional properties "should be mapped to RDF predicates using further context documents", and these contexts "must be added before" the IIIF context.

I also noticed that the rest of the 3.0 schema already accepts extra properties on Canvas, Annotation, Collection and AnnotationCollection (fixtures/3/extension_anno.json shows a GeoJSON extension accepted at the Annotation level), and that the 4.0 schema in this repository does not restrict them on Manifest or AnnotationPage.

Change

I added a patternProperties entry next to additionalProperties: false on manifest and annotationPage:

"patternProperties": {
    "^[A-Za-z][A-Za-z0-9_.-]*:[^/].*$": {}
}

Keys written as compact IRIs (prefix:suffix) are accepted with any value. I kept additionalProperties: false on purpose: unprefixed unknown keys are still rejected, so a misspelled IIIF property is still reported. Absolute IRIs (https://…) do not match, because the suffix may not start with /.

How I tested it

I wrote two fixtures first:

  • fixtures/3/extension_manifest.json, in the good list: an extension context before the IIIF context, ext:project at the Manifest root and ext:note on the Canvas's AnnotationPage.
  • fixtures/3/broken_typo_property.json, in the bad list, as a guard: an otherwise valid Manifest with a misspelled sumary key.

Then I ran both through a local instance of the validator (iiif-validator serve, then POST /validate), one schema change at a time:

Schema extension_manifest.json broken_typo_property.json
main fails: ext:project on /, ext:note on /items[0]/items[0] fails
manifest change only fails: ext:note on /items[0]/items[0] fails
both changes passes fails

I also ran pytest tests/test_validator.py, and it passes. No existing fixture uses a prefixed key, so no other test result changes.

Side effect

While testing, I noticed that jsonschema words the error for an unknown key differently once patternProperties is present:

  • before: Additional properties are not allowed ('sumary' was unexpected)
  • after: 'sumary' does not match any of the regexes: '^[A-Za-z][A-Za-z0-9_.-]*:[^/].*$'

The error path is unchanged.

Happy to adjust the pattern, the fixtures or the wording if you prefer another approach.

The 3.0 schema sets additionalProperties to false on manifest and
annotationPage, so extension properties on these resources fail
validation, although Presentation 3.0 allows them (sections 3 and 4.6).

Accept keys written as compact IRIs (prefix:suffix) through
patternProperties, and keep rejecting unprefixed unknown keys so that
misspelled properties are still reported.
@glenrobson

Copy link
Copy Markdown
Member

Hi, thanks so much for this, and for such a thorough write-up.

I like how neat the solution is, but I’m hesitant to merge it as it stands. The specification doesn’t require extension properties to be namespaced or written as compact IRIs. §3 and §4.6 only say that other properties are allowed and should be mapped to RDF through additional context documents placed before the IIIF context.

With this pattern, the validator would accept prefix:suffix keys but still reject unprefixed ones. In effect it would be enforcing a naming convention that isn’t in the spec, so a spec-compliant Manifest could still fail depending on how its extension keys are named. I’d rather not make the validator stricter than the specification in that particular way.

The alternative, allowing additionalProperties on Manifest and AnnotationPage, has the opposite problem. It would quietly accept typos like sumary, and I think catching those is one of the most useful things the validator does. As you pointed out, that’s already happening at other levels, which isn’t ideal either. (note the misspelling in the current validator should be a separate issue)

Ideally, unknown properties would be reported as warnings rather than errors, but JSON Schema doesn’t support that. We’d need two copies of the schema, a strict one and a lenient one, and keeping them in sync would be hard to maintain. So for now I’d prefer to keep the current behaviour, where unrecognised properties on Manifest and AnnotationPage are reported as errors, and make it clearer in the documentation that some of these errors may be valid extensions you can safely ignore.

Thanks again for taking the time on this.

Instead of accepting only prefixed keys in the schema, keep the schema as it
is on main and sort its additionalProperties errors in the v3 validator:

- on a Manifest or AnnotationPage, a key the schema does not define anywhere
  is reported as a warning (an extension, or a typo such as "sumary");
- a property the schema does define, used where it is not allowed (e.g.
  "annotations" on an AnnotationPage), is still an error;
- additionalProperties errors on other objects are unchanged.

A result with warnings and no errors now passes. validate-dir prints
warnings for passing files too, so they show up in CI logs.
@Zwiterrion Zwiterrion changed the title Allow namespaced extension properties on 3.0 Manifest and AnnotationPage Report unknown properties on 3.0 Manifest and AnnotationPage as warnings Nov 2, 2026
@Zwiterrion

Zwiterrion commented Nov 2, 2026 •

Copy link
Copy Markdown
Author

Thanks for the review, that makes sense.

You're right that the spec doesn't ask for prefixes, I misread it.

About the warnings, I think that is a good process to explore but I don't think it needs two schemas.
v3/schemavalidator.py already post-processes the jsonschema errors (it drops errors from irrelevant oneOf branches and removes duplicates), and ValidationResult already has a warnings list. So I pushed a second commit that keeps the schema exactly as it is on main and sorts the additionalProperties errors there:

  • on a Manifest or AnnotationPage, a key the schema doesn't define anywhere becomes a warning. That covers extensions, prefixed or not, and typos like sumary, which is still reported;
  • a property the schema does define but that isn't allowed there stays an error, e.g. annotations on an AnnotationPage §3.4. "Other types of resource must not have the annotations property"). broken_embedded_annos.json still fails;
  • additionalProperties errors on other objects, such as @none in a language map, are unchanged.

A result with warnings and no errors passes. validate-dir now prints warnings for passing files too, so they still show up in the Action's logs.

For fixtures:

  • extension_manifest.json now uses unprefixed keys (project at the root, note on a nested AnnotationPage): passes with two warnings
  • typo_property.json (renamed from broken_typo_property.json): passes with a warning for sumary
  • broken_typo_missing_label.json: the same typo plus a missing label. Both are on the same path, so this checks that the warning doesn't hide the error when duplicates are removed.

If you'd still rather keep the current behaviour and only document it, I'm happy to close this and open a docs PR instead.

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.

2 participants