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

Sidecar message consumption AVRO deserialization assumes records #220

Open
jlrobins opened this issue Dec 16, 2024 · 0 comments
Open

Sidecar message consumption AVRO deserialization assumes records #220

jlrobins opened this issue Dec 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jlrobins
Copy link
Contributor

jlrobins commented Dec 16, 2024

Avro can serialize lots of toplevel things that are NOT records (primitives, etc.), but RecordDeserializer.java::handleAvro() assumes Record, and croaks when deserializing, say, a key schema describing "just a long encoding of a timestatmp", used as key schema of topic WeatherData within our test custom data cluster.

Schema WeatherData-key:

{
  "logicalType": "timestamp-micros",
  "type": "long"
}

The exception raised:

....
Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to org.apache.avro.generic.GenericData$Record
at io.confluent.idesidecar.restapi.messageviewer.RecordDeserializer.handleAvro(RecordDeserializer.java:134)
...

Enums, Arrays, Maps, Fixed, and primitives could all be the toplevel type, not just Records, and will probably deserialize to distinct java-side classes, not GenericData.Record.

It does not appear to me that JSONSchema or Protobuf will have the same weakness:

  1. As far as I can see, Protobuf messages are always the equivalent of a record, perhaps though just encapsulating a single field.
  2. Despite JSON being similar to Avro in allowing toplevel primitives and arrays (not objects), the deserialization code in sidecar treats as a JsonNode only, which will handle all.
image
@jlrobins jlrobins added the bug Something isn't working label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant