Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfluentSchemaRegistryValidationError when union contains more than one number data type #213

Open
jomo02 opened this issue Sep 9, 2022 · 3 comments

Comments

@jomo02
Copy link

jomo02 commented Sep 9, 2022

Hi together,

I am running into the following error when I try to produce a message:

ConfluentSchemaRegistryValidationError: invalid ["null", "boolean", "double", "long"]: true

The schema was previously registered and the relevant part looks like this:

{
    "name": "value",
    "type": ["null", "boolean", "double", "long"]
}

If I replace "long" e.g. with "string" I am able to produce, but when I'm using any combination of double, float, long and int, I'm getting the described error.

Maybe it has something to do with the fact that unions may not contain more than one schema with the same type (since there is only the number type in Typescript)?

Thanks in advance!

@kinhsloob1-erecruiter
Copy link

Same issue.

ConfluentSchemaRegistryValidationError: invalid ["null", "int", "long", "string"]: 7.5

The schema was previously registered and the relevant part looks like this:

{
    "name": "value",
    "type": ["null", "int", "long", "string"]
}

If I remove "int" from the union, it works.

@stebl
Copy link

stebl commented Feb 16, 2023

Just ran into this as well. Any movement?

@Bahkran
Copy link

Bahkran commented Jun 20, 2024

Hi - realise this is old, but we hit it recently using v3.3.0.

This can be solved by explicitly specifying the type of the union that you are using. It is the same technique used if there are objects in the union.

e.g.

{
    "name": "value",
    "type": ["null", "int", "long", "string"]
}
const registry = new SchemaRegistry({…});
await registry.encode(schemaId, {
  value: { long: 75 },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants