confluent-schema-registry icon indicating copy to clipboard operation
confluent-schema-registry copied to clipboard

Upgrading to 2.0.1 is giving ConfluentSchemaRegistryArgumentError on schema registration action

Open sureshballa opened this issue 3 years ago • 2 comments

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));

sureshballa avatar May 17 '21 14:05 sureshballa

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.

Nevon avatar May 17 '21 15:05 Nevon

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 }});

sureshballa avatar May 17 '21 16:05 sureshballa