Page MenuHomePhabricator

jsonschema-tools tests should fail if schema $id does not match title or path
Closed, ResolvedPublic

Description

https://gerrit.wikimedia.org/r/c/schemas/event/secondary/+/757879 is a fix to a change that CI should not have allowed us to merge. We should make sure it errors next time that happens.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Here is an example of how we are already asserting that the schema title match the schema file path:
https://github.com/wikimedia/jsonschema-tools/blob/master/lib/tests/structure.js#L179-L182

We should make a another similar assertion just below that the schema $id matches the schema file path.
I.e. if the $id is /rdf_streaming_updater/reconcile/1.0.0, relativeSchemaPath should be rdf_streaming_updater/reconcile

That part of the code is already asserting things about schemaInfoForContentType, which is a 'schemaInfo' object as returned by schemaPathToInfo function. That object has a schema field, so you should be able to access the $id as schemaInfoForContentType.schema['$id'].

Aklapper added a subscriber: NOkafor-WMF.

Resetting inactive assignee. Please reassign tasks when offboarding - thanks.)

Ottomata triaged this task as Medium priority.