[ https://issues.apache.org/jira/browse/AVRO-2126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16952827#comment-16952827 ]
Alperen Koksel commented on AVRO-2126: -------------------------------------- [~pederpansen] In my case I overcame ''Can't access branch index' with by first decoding the message to b64. But now I got tuple index out of range error. [~ryanskraba] I believe he 's using python-kafka and using avro.io library to deserialize. I'm using similar structure. I think it shouldn't matter because confluent kafka library is also using avro.io library to deserialize. It should look like this.. {code:java} // schema_path = "users.avsc" schema = avro.schema.Parse(open(schema_path).read()) def from_avro(msg): msg_decoded=base64.b64decode(msg.decode('ascii')) bytes_reader = io.BytesIO(msg_decoded) decoder = avro.io.BinaryDecoder(bytes_reader) reader = avro.io.DatumReader(schema, schema) user1 = reader.read(decoder) return user1 consumer = KafkaConsumer('topic_name_here', bootstrap_servers=['0.serveraddress.com:9092', '1.serveraddress.com:9092', '2.serveraddress.com:9092'], auto_offset_reset='earliest', group_id='my_group', value_deserializer=from_avro ) for msg in consumer: print(msg) {code} > avro.io.SchemaResolutionException: Can't access branch index 36 for union > with 2 branches > ----------------------------------------------------------------------------------------- > > Key: AVRO-2126 > URL: https://issues.apache.org/jira/browse/AVRO-2126 > Project: Apache Avro > Issue Type: Bug > Components: python > Affects Versions: 1.8.2 > Environment: Python 3.5.2, avro-python3 1.8.2 > Reporter: Jurgis Pods > Priority: Major > > I get the following error when decoding messages from Kafka via avro-python3: > {code} > avro.io.SchemaResolutionException: Can't access branch index 36 for union > with 2 branches > Writer's Schema: [ > "null", > "string" > ] > Reader's Schema: [ > "null", > "string" > ] > {code} > Relevant code producing this error: > {code} > import avro.schema > import avro.io > import io > def parse_avro(value, schema): > bytes_reader = io.BytesIO(value) > decoder = avro.io.BinaryDecoder(bytes_reader) > reader = avro.io.DatumReader(schema) > return reader.read(decoder) > # msg: Message from Kafka, schema: avro.schema.Schema from Confluent Schema > Registry > parse_avro(msg.value, avro_schema) > {code} > I have no idea where the number 36 might come from. -- This message was sent by Atlassian Jira (v8.3.4#803005)