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

avro_specific.Deserialize() returns wrong things #843

Closed
6 of 7 tasks
falau opened this issue Aug 9, 2022 · 1 comment
Closed
6 of 7 tasks

avro_specific.Deserialize() returns wrong things #843

falau opened this issue Aug 9, 2022 · 1 comment

Comments

@falau
Copy link

falau commented Aug 9, 2022

Description

The method Deserialize() of the specific Avro deserializer has the signature like this:

func (s *SpecificDeserializer) Deserialize(topic string, payload []byte) (interface{}, error) {

Although this method is not documented(nor tested) well, I expect the first return should be of the message type produced by the MessageFactory for the deserializer.
However, the first returned object is the return of vm.Eval(), and it's an error object:

return vm.Eval(r, deser, avroMsg), nil

This behavior basically makes Deserialize() unusable since usually there is no way for the caller of Deserialize() to access the message produced by the MessageFactory.

How to reproduce

  • Init a Schema Registry client and prepare a gogen-avro generated struct
  • with the following code:
	// srClient: the Schema Registry client
	deser, _ := avro.NewSpecificDeserializer(srClient, serde.ValueSerde, avro.NewDeserializerConfig())
	deser.MessageFactory = func(subject, name string) (interface{}, error) {
		// MyMessageType: a specific type generated by gogen-avro
		var myMessage MyMessageType
		return &myMessage, nil
	}
	decodedValue, err := deser.Deserialize(*kafkaMsg.TopicPartition.Topic, kafkaMsg.Value)
        // decodedValue would be a nil if everything goes well :/

Checklist

Please provide the following information:

  • confluent-kafka-go and librdkafka version (LibraryVersion()): v1.9.2 / v1.9.2
  • Apache Kafka broker version: irrelevant
  • Client configuration: ConfigMap{...}: irrelevant
  • Operating system: irrelevant
  • Provide client logs (with "debug": ".." as necessary): irrelevant
  • Provide broker log excerpts: irrelevant
  • Critical issue
@milindl
Copy link
Contributor

milindl commented Aug 26, 2022

Thanks for reporting this, we're looking into it.

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

2 participants