0

Trying to Update existing schema in SchemaRegistry, but having error: Schema being registered is incompatible with an earlier schema for subject "kafka-2906-value"

Existing JSON schema: {"subject":"kafka-2906-value","version":1,"id":12,"schemaType":"JSON","schema":"{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"InvoiceId":{"type":"integer"},"InvoiceNo":{"type":"string"},"Amount":{"type":"number"},"IsPaid":{"type":"boolean"}}}

Updated curl command with JSON schema: curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"schemaType":"JSON","schema":"{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"InvoiceId":{"type":"integer"},"InvoiceNo":{"type":"string"}}}"}'
http://schema-registry-1234567.xx-xxx-1.eee.amazonaws.com:8082/subjects/kafka-2906-value/versions

Padmaraj
  • 1
  • 1

1 Answers1

0

In the previous version IsPaid is a mandatory field. In the subsequent one it is not. Schema versions have to be compatible with each other. This can be further looked at

https://docs.confluent.io/platform/current/schema-registry/develop/using.html#sr-top-level-config.

Based on the requirements you can customize the compatibility of the schemas. More details on the compatibility is documented here

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

Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24
  • Appreciate for your response. But for Full compatibility tried to add new default property without deleting any existing schema properties having same issues. Or is it like in schema we have to mention which are required properties ? or is it like it considers all as required properties if not explicitly specified ? – Padmaraj Jul 07 '22 at 07:44
  • I'd have to check the bolts , but think that you had a prior version that had a non nullable property IsPaid. May be you have to specify that as a union type with some nullable value in the prior version for it to be compatible ? – Ramachandran.A.G Jul 07 '22 at 07:48
  • Please, let me know how to add default property in JSON schema as trying to add below curl its not getting updated on latest version – Padmaraj Jul 13 '22 at 06:37
  • curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"schemaType":"JSON","schema":"{\"$schema\": \"http://json-schema.org/draft-04/schema#\", \"title\": \"Invoice\", \"type\": \"object\", \"additionalProperties\": false, \"required\": [ \"InvoiceId\" ], \"properties\": { \"Desc\": { \"type\": [ \"null\", \"string\" ] }, \"InvoiceId\": { \"type\": \"integer\", \"format\": \"int64\" }, \"InvNo\": { \"type\": [ \"null\", \"string\" ] }, \"IsPaid\": { \"type\": \"boolean\" } }}"}' \ http://el.onaws.com:xx/subjects/update-schema-value/versions – Padmaraj Jul 13 '22 at 07:02