Page MenuHomePhabricator

Schema compatibility check for changing event schemas fails when adding to the middle of an array
Closed, ResolvedPublic

Description

See PS2 of https://gerrit.wikimedia.org/r/c/schemas/event/secondary/+/650031 for an example. The change is:

diff --git a/jsonschema/analytics/legacy/homepagemodule/current.yaml b/jsonschema/analytics/legacy/homepagemodule/current.yaml
index 7f529fa..574e1b2 100644
--- a/jsonschema/analytics/legacy/homepagemodule/current.yaml
+++ b/jsonschema/analytics/legacy/homepagemodule/current.yaml
@@ -2,7 +2,7 @@
 description: >-
   Logs interactions with the homepage modules on the Special:Homepage provided
   by the GrowthExperiments extension
-$id: /analytics/legacy/homepagemodule/1.0.0
+$id: /analytics/legacy/homepagemodule/1.1.0
 $schema: 'https://json-schema.org/draft-07/schema#'
 type: object
 allOf:
@@ -262,6 +262,7 @@
             type: string
             enum:
               - generic
+              - banner
               - start
               - start-account
               - start-tutorial

the CI result is:

23:13:18   1) Schema Compatibility in Repository ./jsonschema/
23:13:18        analytics/legacy/homepagemodule
23:13:18          Major Version 1
23:13:18            1.1.0 must be compatible with 1.0.0:
23:13:18 
23:13:18       AssertionError [ERR_ASSERTION]: Error at path: .properties.event.properties.module.enum.1
23:13:18       + expected - actual
23:13:18 
23:13:18       -banner
23:13:18       +start
23:13:18       
23:13:18       at new AssertionError (internal/assert.js:269:11)
23:13:18       at isCompatible (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:58:15)
23:13:18       at isCompatible (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:52:25)
23:13:18       at isCompatible (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:52:25)
23:13:18       at isCompatible (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:52:25)
23:13:18       at isCompatible (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:52:25)
23:13:18       at isCompatible (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:52:25)
23:13:18       at isCompatible (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:52:25)
23:13:18       at Context.it (node_modules/@wikimedia/jsonschema-tools/lib/tests/compatibility.js:87:37)

Adding the new element to the end of the array works, so this is not a big obstacle in practice, but usually I'd want large lists to be either alphabetical or use some conceptual order (like the order of the steps in some workflow), not chronological.

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Compatibility test fixes - required and enumrepos/data-engineering/jsonschema-tools!30ebysansgithub/fork/ottomata/requiredmaster
Customize query in GitLab