karapace
karapace copied to clipboard
Check compatibility API does not support verbose mode
What happened?
The check compatibility of a schema API does not support verbose mode.
When using the Confluent Schema Registry client against Karapace, this makes the call to the function testCompatibilityVerbose
wrong. This function is based on the verbose mode: if the schema is incompatible, it returns an error list and an empty list otherwise. With Karapace, it will always return an empty list.
What did you expect to happen?
Karapace should support verbose mode.
The URL corresponding to this mode on Confluent Schema Registry is /compatibility/subjects/{subject}/versions/{version}?verbose=true
What else do we need to know?
Karapace used: latest (using the docker-compose provided) at the moment I create this issue.
Steps to reproduce:
Create a schema
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"schemaType": "JSON", "schema": "{\\"$id\\":\\"https://mycompany.com/myrecord\\",\\"$schema\\":\\"https://json-schema.org/draft/2019-09/schema\\",\\"additionalProperties\\":false,\\"description\\":\\"Json schema for MyRecord\\",\\"properties\\":{\\"id\\":{\\"type\\":\\"string\\"},\\"key3\\":{\\"type\\":[\\"string\\",\\"null\\"]},\\"name\\":{\\"type\\":[\\"string\\",\\"null\\"]}},\\"required\\":[\\"id\\",\\"key3\\"],\\"title\\":\\"MyRecord\\",\\"type\\":\\"object\\"}"}' \
http://localhost:8081/subjects/test-key-json-schema/versions
Result: {"id":1}
Compatibility on Karapace
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"schemaType": "JSON", "schema": "{\\"$id\\":\\"https://mycompany.com/myrecord\\",\\"$schema\\":\\"https://json-schema.org/draft/2019-09/schema\\",\\"additionalProperties\\":false,\\"description\\":\\"Json schema for MyRecord\\",\\"properties\\":{\\"id\\":{\\"type\\":\\"string\\"},\\"new\\":{\\"type\\":[\\"string\\",\\"null\\"]},\\"key3\\":{\\"type\\":[\\"string\\",\\"null\\"]},\\"name\\":{\\"type\\":[\\"string\\",\\"null\\"]}},\\"required\\":[\\"id\\",\\"key3\\",\\"new\\"],\\"title\\":\\"MyRecord\\",\\"type\\":\\"object\\"}"}' \
'http://localhost:8081/compatibility/subjects/test-key-json-schema/versions/1?verbose=true'
Result: {"is_compatible": false}
Compatibility on Confluent
curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"schemaType": "JSON", "schema": "{\\"$id\\":\\"https://mycompany.com/myrecord\\",\\"$schema\\":\\"https://json-schema.org/draft/2019-09/schema\\",\\"additionalProperties\\":false,\\"description\\":\\"Json schema for MyRecord\\",\\"properties\\":{\\"id\\":{\\"type\\":\\"string\\"},\\"new\\":{\\"type\\":[\\"string\\",\\"null\\"]},\\"key3\\":{\\"type\\":[\\"string\\",\\"null\\"]},\\"name\\":{\\"type\\":[\\"string\\",\\"null\\"]}},\\"required\\":[\\"id\\",\\"key3\\",\\"new\\"],\\"title\\":\\"MyRecord\\",\\"type\\":\\"object\\"}"}' \
'http://localhost:8081/compatibility/subjects/test-key-json-schema/versions/1?verbose=true'
Result: {"is_compatible":false,"messages":["Found incompatible change: Difference{jsonPath='#/properties/new', type=REQUIRED_PROPERTY_ADDED_TO_UNOPEN_CONTENT_MODEL}"]}
This is still an issue with kafka-schema-registry-maven-plugin version 6.2.0 and above.
The workaround we use at the moment is to pin kafka-schema-registry-maven-plugin to 6.1.0, but that comes with the tradeoff of not having access to the set-compatibility
goal available in newer versions of kafka-schema-registry-maven-plugin.