question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jsonschema Forward compatibility fails when deleting an optional field

See original GitHub issue

According to this, deleting an optional field is allowed in Forward compatibility.

Having this schema:

{
  "title": "Person",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "lastName": {
      "type": "string",
      "description": "The person's last name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    }
  }
}

and setting compatibility rule to Forward, and trying to add a new version:

{
  "title": "Person",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string",
      "description": "The person's first name."
    },
    "age": {
      "description": "Age in years which must be equal to or greater than zero.",
      "type": "integer",
      "minimum": 0
    }
  }
}

the compatibility check is failing with error:

{causes: [{description: "OBJECT_TYPE_PROPERTY_SCHEMAS_NARROWED", context: "/propertySchemasAdded"}],…}
causes: [{description: "OBJECT_TYPE_PROPERTY_SCHEMAS_NARROWED", context: "/propertySchemasAdded"}]
detail: "io.apicurio.registry.rules.RuleViolationException
error_code: 409
message: "Incompatible artifact: person [JSON], num of incompatible diffs: {1}"
name: "RuleViolationException"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jsenkocommented, Apr 26, 2022

I’m thinking however that my argument may not be valid if there is "additionalProperties":false set. EDIT: I’ve tested our current compatibility checker with "additionalProperties": false and it works as expected.

1reaction
jsenkocommented, May 16, 2022

Yes, the compatibility checker must be pessimistic because it works based on general rules. There was already some interest from the community to introduce a less strict checking, but I’m not yet sure how it would look like in practice. A straightforward alternative would be to add an option to force an override, on user’s own risk, if they are 100% sure that it’s safe for their application. Registry would then need to take this into account when doing transitive checks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON-Schema forward compatibility doesn't allow the removal ...
I think schema validation for json-schema is bugged. I cannot remove an optional field on a FORWARD compatible schema. The long version: Looking ......
Read more >
AVRO schema optional fields are not compatible
E.g. deleting an non-optional field is not a forward compatible change. The Confluent schema registry is only made to transport the writer ...
Read more >
Schema Evolution and Compatibility - Confluent Documentation
Delete fields ; Add optional fields. All previous versions, Consumers. FORWARD. Add fields; Delete optional fields. Last version, Producers.
Read more >
Understanding JSON Schema Compatibility - Robert Yokota
When removing a property in a backward compatible manner, the schema of “additionalProperties” in the new version of the schema must be backward ......
Read more >
AWS Glue Schema Registry
You can use this choice to check compatibility against all previous schema versions when you delete fields or add optional fields. FORWARD: This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found