Skip to content

Protobuf schema compatibility check actual errors are not returned to clients #7068

@abhimoondra

Description

@abhimoondra

Description

Registry Version: 3.1.6
Persistence type: sql

Currently if there is a compatibility error while registering protobuf schemas, the actual error is not surfaced to the client. The error is always :

The new version of the protobuf artifact is not backward compatible. at /

Ideally the actual error should be returned to clients such as "use of reserved fields" or "Field tag changed" etc.
It would be very helpful for clients to correct the mistake.

Environment

Running APICurio schema registry locally in a docker container.
COMPATIBILITY LEVEL : BACKWARD

Steps to Reproduce

# Create artifact
curl -X POST 'http://127.0.0.1:8080/apis/registry/v3/groups/default/artifacts' \
  -H 'Content-Type: application/json' \
  -d '{
    "artifactId": "UserCreatedEvent.proto",
    "artifactType": "PROTOBUF"
  }'

# Create Schema Version
curl -X POST 'http://127.0.0.1:8080/apis/registry/v3/groups/default/artifacts/UserCreated.proto/versions' \
  -H 'Content-Type: application/json' \
  -d '{
    "version": "1",
    "name": "UserCreated.proto",
    "content": {
      "content": "syntax = \"proto3\";\npackage demo;\n\nmessage UserCreated {\n  string user_id = 1;\n  string name = 2;\n  int32 age = 3;\n  string email = 4;\n}\n",
      "contentType": "application/x-protobuf"
    }
  }'

# Create Schema Version with an incompatible changed (for this scenario I have changed the tag number of field email from 4 to 5)
curl -X POST 'http://127.0.0.1:8080/apis/registry/v3/groups/default/artifacts/UserCreated.proto/versions' \
  -H 'Content-Type: application/json' \
  -d '{
    "version": "2",
    "name": "UserCreated.proto",
    "content": {
      "content": "syntax = \"proto3\";\npackage demo;\n\nmessage UserCreated {\n  string user_id = 1;\n  string name = 2;\n  int32 age = 3;\n  string email = 5;\n}\n",
      "contentType": "application/x-protobuf"
    }
  }'

Error Response:

{"causes":[{"description":"The new version of the protobuf artifact is not backward compatible.","context":"/"}],"detail":"Incompatible artifact: UserCreated.proto [PROTOBUF], num of incompatible diffs: {1}, list of diff types: [The new version of the protobuf artifact is not backward compatible. at /] Causes: The new version of the protobuf artifact is not backward compatible. at /","title":"Incompatible artifact: UserCreated.proto [PROTOBUF], num of incompatible diffs: {1}, list of diff types: [The new version of the protobuf artifact is not backward compatible. at /]","status":409,"name":"RuleViolationException"}

Expected vs Actual Behaviour

Expected :
Actual error should be shown, such as "Conflict, field id changed for 'email'. Before : 4, after : 5".

Actual:

Generic error is shown.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions