riferrei / srclient

Golang Client for Schema Registry
Apache License 2.0
235 stars 70 forks source link

Failing to load schema with references #111

Open bbrcan opened 2 months ago

bbrcan commented 2 months ago

Hi there,

I have the following enum called Status:

{
  "schema": {
    "type": "enum",
    "namespace": "test",
    "name": "Status",
    "symbols": ["Pending", "Enroute", "Arrive", "Complete"]
  }
}

And the following schema called Route:

{
  "schema": {
    "type": "record",
    "namespace": "test",
    "name": "Route",
    "fields": [
      {
        "name": "orgId",
        "type": "string"
      },
      {
        "name": "status",
        "type": "Status"
      }
    ]
  },
  "references": [
    {
      "name": "test.Status",
      "subject": "Status",
      "version": 1
    }
  ]
}

When I try to load the Route schema via either GetSchemaByVersion or GetSchema, I get back:

schema registry error: Record "test.Route" field 2 ought to be valid Avro named type: unknown type name: "Status"

Note I am using sc.CodecCreationEnabled(true). Happy to disable this but then I'm not quite sure how I'd load the codec with the references.

I've also tried referencing the Status type as test.Status in the Route schema, to no avail.

Can you shed any light on why this might be occurring? Thank you

Using srclient 0.7.0, Golang 1.23

bbrcan commented 2 months ago

For those interested I've managed to get around this by the following: