You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to use a schema-registry avro schema to encode a kafka message key. Most of the time, the key is pretty simple like a string or a long. Other times, it's more complex and I can use a record type.
When the key isn't a record, but it's just a primitive type, I'm struggling to register the schema. For example:
ConfluentSchemaRegistryArgumentError: Invalid name: undefined
at AvroHelper.validate (node_modules/@kafkajs/confluent-schema-registry/src/AvroHelper.ts:26:13)
at SchemaRegistry.register (node_modules/@kafkajs/confluent-schema-registry/src/SchemaRegistry.ts:106:12)
at Context.<anonymous> (test/service-bus/serde_test.ts:45:28)
at processImmediate (internal/timers.js:461:21)
which have schemas that reduce to the same avro canonical form as the first example, but these give the same error.
I can register the schemas with the registry directly, eg:
$ curl -X POST localhost:8081/subjects/my-topic-key/versions -H "Content-Type: application/json" -d '{"schema": "\"string\""}'
{"id":1}
$ curl -X POST localhost:8081/subjects/my-topic-key/versions -H "Content-Type: application/json" -d '{"schema": "{\"type\": \"string\"}"}' # NB Same canonical form -> same id from registry
{"id":1}
$ curl -X POST localhost:8081/subjects/my-topic-key/versions -H "Content-Type: application/json" -d '{"schema": "{\"name\": \"foo\", \"type\": \"string\"}"}' # NB Same canonical form again
{"id":1}
$ curl localhost:8081/schemas/ids/1
{"schema":"\"string\""}
which makes me think that AvroHelper.validate() might be a bit too strict in requiring a name field on the schema.
The text was updated successfully, but these errors were encountered:
Commenting on my own issue here as I understand more...
I suspect the reason for requiring a name on the schema is because of the implicit subject naming that uses the name field from the schema. Would it make sense to relax this constraint in AvroHelper.validate() if the subject name were passed in to register()?
I'd like to use a schema-registry avro schema to encode a kafka message key. Most of the time, the key is pretty simple like a string or a long. Other times, it's more complex and I can use a record type.
When the key isn't a record, but it's just a primitive type, I'm struggling to register the schema. For example:
gives:
I've also tried:
which have schemas that reduce to the same avro canonical form as the first example, but these give the same error.
I can register the schemas with the registry directly, eg:
which makes me think that
AvroHelper.validate()
might be a bit too strict in requiring aname
field on the schema.The text was updated successfully, but these errors were encountered: