confluent-kafka-dotnet icon indicating copy to clipboard operation
confluent-kafka-dotnet copied to clipboard

Avro.AvroException: Unable to find type 'example.test.value' when Namespace isn't 'example.test.value'

Open teimyBr opened this issue 2 years ago • 4 comments

Description

Confluent.Kafka nuget version = 1.7.0 and 1.8.2 Confluent.SchemaRegistry Version=1.7.0 1.8.2 Confluent.SchemaRegistry.Serdes.Avro Version= 1.7.0 and 1.8.2 Apache Kafka version = 2.8.0 No Critical issue

ERROR xxxx - Kafka1 | Error while consuming from topics Confluent.Kafka.ConsumeException: Local: Value deserialization error ---> Avro.AvroException: Unable to find type 'example.test.value' in all loaded assemblies at Avro.Specific.ObjectCreator.<>c__DisplayClass14_0.<FindType>b__0(String _) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Avro.Specific.ObjectCreator.GetType(String name, Type schemaType) at Avro.Specific.SpecificDefaultReader.ReadRecord(Object reuse, RecordSchema writerSchema, Schema readerSchema, Decoder dec) at Avro.Generic.DefaultReader.Read[T](T reuse, Decoder decoder) at Confluent.SchemaRegistry.Serdes.SpecificDeserializerImpl1.Deserialize(String topic, Byte[] array) at Confluent.SchemaRegistry.Serdes.AvroDeserializer1.DeserializeAsync(ReadOnlyMemory1 data, Boolean isNull, SerializationContext context) at Confluent.Kafka.SyncOverAsync.SyncOverAsyncDeserializer1.Deserialize(ReadOnlySpan1 data, Boolean isNull, SerializationContext context) at Confluent.Kafka.Consumer2.Consume(Int32 millisecondsTimeout) --- End of inner exception stack trace --- at Confluent.Kafka.Consumer2.Consume(Int32 millisecondsTimeout) at Confluent.Kafka.Consumer2.Consume(TimeSpan timeout)

This Error comes when consuming Avro Data from a Topic.

This error only comes when the C# namespace in that is the Avro Class isn't "example.test.value"

When changing the namespace of the class to example.test.value the error is fixed.

I want that i can use the example.test.value Schema in a Namespace that isn't example.test.value.

Is that possible?

teimyBr avatar Mar 15 '22 20:03 teimyBr

i think this is an issue with the avro library

mhowlett avatar Mar 16 '22 02:03 mhowlett

So open an Issue in the Avro library?

teimyBr avatar Mar 16 '22 06:03 teimyBr

Perhaps, I'm missing the point. [AVRO-3047] states that the namespace of the schema is expected to match the namespace of the C# class. It is not clear to me why is this expected? If producer and consumer are written in different languages, then what the schema namespace and name have to do with actual namespace and class names of the producer and consumer data / event classes?

This is also similar to issue 1034. I will create PR with the test and fix shortly.

sergemat avatar Jun 21 '22 22:06 sergemat

resolved https://github.com/confluentinc/confluent-kafka-dotnet/pull/1847

mhowlett avatar Oct 11 '22 00:10 mhowlett

Is this fix already part of a release? Im running into a similar issue

JBastiaan avatar Oct 27 '22 10:10 JBastiaan

It's listed in v1.9.2 release:

Enhanced the Avro Specific Deserializer to ignore the type namespace

KalleOlaviNiemitalo avatar Nov 01 '22 08:11 KalleOlaviNiemitalo

I'm getting this error on nested objects

Yasinkus avatar Mar 08 '23 14:03 Yasinkus

@Yasinkus we had a similar problem in our project. We use paket as our dependency manager, and got the following Exception while consuming: System.AggregateException : Mindestens ein Fehler ist aufgetreten. ----> Confluent.Kafka.ConsumeException : Local: Value deserialization error ----> Avro.AvroException : Unable to find type '-----' in all loaded assemblies in field ---- ----> Avro.AvroException : Unable to find type '-----' in all loaded assemblies

In our case the assemblyBindung to System.CodeDom was missing, but no way to get this information from the error message.

.netFramework 4.8 Confluent.Kafka 2.1.1 Confluent.SchemaRegistry 2.1.1 Confluent.SchemaRegistry.Serdes.Avro 2.1.1 Apache.Avro 1.11.1

madeu avatar Jun 23 '23 16:06 madeu