2

How to check previous schemas registered in Registry?

I'm trying to register but I am getting "Schema being registered is incompatible with an earlier schema for subject" exception

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

3 Answers3

0

Compatibility checks will only operate against the latest stored subject version

https://docs.confluent.io/platform/current/schema-registry/develop/api.html#sr-api-compatibility

You'd check the schemas using the subject and version number(s)

https://docs.confluent.io/platform/current/schema-registry/develop/api.html#get--subjects-(string-%20subject)-versions-(versionId-%20version)-schema


Neither will tell you "why" it is incompatible, but Avro has clear documentation on that, for example

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Is there a way to find out why the schema fails compatibility check when I receive `"is_compatible": "false"` when calling `/compatibility/subjects/{schema_name}/versions/{last_version}` ? – d56 Jul 27 '22 at 16:20
  • As answered, the API doesn't return this information. You will need to read the relevant documentation for the serialization format you are using. Or you can create a new question here and upload both of your schemas. – OneCricketeer Jul 27 '22 at 17:40
0

You can try the following

  • Command to get all versions of the previously registered schemas

SchemaRegistryURL/subjects/topicname-value/versions

  • Command to get a specific version of all previously registered Schemas

SchemaRegistryURL/subjects/topicname-value/versions/version

Schema Compatibility option might not set it correctly, in which case you can reset the Compatibility using the following command and try re-registering your schema.

curl -k -X PUT -H "Content-Type:application/vnd.schemaregistry.v1+json" --data '{"compatibility": "NONE"}' SchemaRegistryURL/config/topic-value

From https://docs.confluent.io/platform/current/schema-registry/avro.html#summary

Compatibility

Transitive compatibility checking is important once you have more than two versions of a schema for a given subject. If compatibility is configured as transitive, then it checks compatibility of a new schema against all previously registered schemas; otherwise, it checks compatibility of a new schema only against the latest schema.

For example, if there are three schemas for a subject that change in order X-2, X-1, and X then:

transitive: ensures compatibility between X-2 <==> X-1 and X-1 <==> X and X-2 <==> X

non-transitive: ensures compatibility between X-2 <==> X-1 and X-1 <==> X, but not necessarily X-2 <==> X

The Confluent Schema Registry default compatibility type BACKWARD is non-transitive, which means that it’s not BACKWARD_TRANSITIVE. As a result, new schemas are checked for compatibility only against the latest schema.

BACKWARD: (default) consumers using X-2 can read data written by producers X-1

BACKWARD_TRANSITIVE: consumers using X-2 can read data written by producers using X-1, and X

FORWARD: consumers using X-1 can read data written by producers using X-2

FORWARD_TRANSITIVE: consumers using X-1 or X can read data written by producers using X-2

FULL: the new schema is forward and backward compatible with the latest registered schema

FULL_TRANSITIVE: the new schema is forward and backward compatible with all previously registered schemas

NONE: schema compatibility checks are disabled

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
ChristDist
  • 572
  • 2
  • 8
0

It is explained in Schema Evolution.

The Confluent Schema Registry default compatibility type is BACKWARD so you cannot add more fields or change datatype.

You need to change the compatibility.

https://docs.confluent.io/platform/current/schema-registry/avro.html#schema-evolution-and-compatibility

Luis Estrada
  • 371
  • 7
  • 20