question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to register a schema which references twice the same complex type throws SchemaParseException

See original GitHub issue

We’re using the dynamic schema registration of apicurio, and since the latest upstep, we’re facing the following error from time to time:

org.apache.avro.SchemaParseException: Can't redefine: com.xxx.yyy

Digging a bit deeper in the code, it seems this is a regression introduced in 2.2.2.Final (2.2.1 was still working). More specific here: https://github.com/Apicurio/apicurio-registry/blob/a28493615587946eb41b48fd778cf758e6129c71/serdes/avro-serde/src/main/java/io/apicurio/registry/serde/avro/AvroSchemaParser.java#L75 The resolvedReferences contains duplicates, which makes the schema.toString() crash.

I created a reproduction unit test. It tries to register the following schema:

{
  "namespace": "com.kubetrade.schema.trade",
  "type": "record",
  "name": "AvroSchemaF",
  "fields": [
    {
      "name": "schemaE1",
      "type": "com.kubetrade.schema.trade.AvroSchemaE"
    },
    {
      "name": "schemaE2",
      "type": "com.kubetrade.schema.trade.AvroSchemaE"
    },
    {
      "name": "key",
      "type": "string"
    }
  ]
}

However I don’t see exactly on how this should be fixed, can somebody assist with that?

PR: https://github.com/Apicurio/apicurio-registry/pull/2740

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TomBillietKlarriocommented, Sep 29, 2022

I can confirm it works fine now in 2.3.0.Final, thanks for the fix.

1reaction
carlesarnalcommented, Sep 9, 2022

Ok, I understand now this issue better, thanks for the reproducer. The issue the other PR fixed is actually different. I have created https://github.com/Apicurio/apicurio-registry/pull/2775 that actually solves this issue, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema registry is not accepting a type by reference
expression. This is thrown by the schema registry. It will upload with no problems.
Read more >
Error Registering Avro Schema | Multiple Schemas In One Topic
Kafka throws this exception due to a compatibility issue since the current schema is not compatible with the earlier schema registered on ...
Read more >
[jira] [Commented] (AVRO-2145) Can't generate Javadoc on ...
public static Protocol parse(File file) throws IOException { return parse(Schema. ... Sets the field's type to the schema by name reference.
Read more >
kafka-avro-console-producer throwing org.apache.avro ...
I am trying to send a avro message by registering the schema in confluent schema-registry: [appuser@schema-registry bin]$ .
Read more >
subject:"Avro schema" - The Mail Archive
Try it out yourself at: https://bolcom.github.io/avro-schema-viewer >> Learn more ... the above under a complex type like a record if I want complex...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found