confluent-schema-registry
confluent-schema-registry copied to clipboard
Upgrading to 2.0.1 is giving ConfluentSchemaRegistryArgumentError on schema registration action
We are trying to upgrade our service with latest version of 2.0.1 and we are getting below error when we try to register schema as per documentation available at https://kafkajs.github.io/confluent-schema-registry/docs/v2 Please help us if we are doing anything wrong here.
Error details Exception name: ConfluentSchemaRegistryArgumentError
const schemaString = JSON.stringify(schema) await registry.register({ type: SchemaType.AVRO, schema: schemaString })
When we investigated the source, it looks like register method signature is different than what is documented. The signature is like register(schema, userOpts)
So, we have tried to update the code to match the above signature but no luck
schemaRegisterResult = await this._schemaRegistry.register(JSON.parse(event.schema));
The easiest thing might be to look at the types directly. schema
can be of several different types, but for Avro, it looks like this: https://github.com/kafkajs/confluent-schema-registry/blob/f9bd3edc5ddb9738af232a376c15bd70efc2eef8/src/%40types.ts#L52-L55
In other words, the example from the docs appears to be correct. The first argument is an object with a type
and a schema
. The second, optional parameter, are additional options.
The ConfluentSchemaRegistryArgumentError provides a message that provides more information on what's wrong. I would guess it's either an invalid schema type, or an invalid schema.
Hi @Nevon, we haven't updated anything else, all current schemas works good in older version of schema registry. This issue is happening only when we migrate to version 2. And for exception, we are just getting below object and noting else to debug this further. Please help.
{"name":"ConfluentSchemaRegistryArgumentError"}
This is our new initialisation code:
this._schemaRegistry = new SchemaRegistry({ host: kafkaConfiguration.KAFKA_SCHEMA_REGISTRY_URL, auth: { username: kafkaConfiguration.KAFKA_SCHEMA_REGISTRY_USERNAME, password: kafkaConfiguration.KAFKA_SCHEMA_REGISTRY_PASSWORD, }, }, {[SchemaType.AVRO]: { noAnonymousTypes: true }});