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

Confusing 400 errors related to json serialization/deserialization

Open Givemeurcookies opened this issue 10 months ago • 0 comments

Greetings!

I wanted to give some feedback after helping out with debugging some code related to the schema registry. In POST /subjects/:subject/versions - if you pass a JSON schema as an object instead of a string, it will give the error:

{
  error_code: 400,
  message: ‘Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)’
}

This gives a vague hint about what is happening (there's an object somewhere where there's supposed to be a string), but makes it sound like there's an issue with the serialization of the "parent" JSON object and not the schema property (.schema). It's a fairly easy mistake to do, so a more descriptive error message would help prevent some headaches.

Reproduction

To make it a bit more clear, here's how to reproduce the error

{
    "schema": {"type":"object", "properties": {name": {"type": "number"}},
    "schemaType": "JSON"
}

Givemeurcookies avatar Aug 18 '23 14:08 Givemeurcookies