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.

org.apache.avro.SchemaParseException: Illegal character in: return$

See original GitHub issue

Hi,

Given:

@namespace( "foo.bar" )
protocol AProtocol {
  record A {
    union { null, int } id = null;
    union { null, string } return = null;
  }
}
  • Using: addSbtPlugin("com.julianpeeters" % "sbt-avrohugger" % "2.0.0-RC17")

It gets compiled to (correct and working):

case class A(id: Option[Int] = None, `return`: Option[String] = None)
  • Using: addSbtPlugin("com.julianpeeters" % "sbt-avrohugger" % "2.0.0-RC18")

It gets compiled to:

case class A(id: Option[Int] = None, return$: Option[String] = None)

In my case I eventually get following exception:

vulcan.AvroException$$anon$1: org.apache.avro.SchemaParseException: Illegal character in: return$
  at vulcan.AvroException$.apply(AvroException.scala:18)
  at vulcan.AvroError$$anon$3.throwable(AvroError.scala:282)
  at fs2.kafka.vulcan.AvroDeserializer$.$anonfun$using$extension$3(AvroDeserializer.scala:55)

Caused by: org.apache.avro.SchemaParseException: Illegal character in: return$
  at org.apache.avro.Schema.validateName(Schema.java:1566)
  at org.apache.avro.Schema.access$400(Schema.java:91)
  at org.apache.avro.Schema$Field.<init>(Schema.java:546)
  at org.apache.avro.Schema$Field.<init>(Schema.java:585)

Only workaround I’ve found is sticking to RC17 version.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
julianpeeterscommented, Feb 17, 2022

Awesome, thanks very much for the eyes and the fix. Released as avrohugger 1.0.0 and sbt-avrohugger 2.0.0

0reactions
mcenkarcommented, Feb 16, 2022

Hi,

I had a quick look and I think we don’t need to do any config for this. It would be breaking change, but it would break a bug that’s there right now. I added PR here, right now it’s failing.

The only places where I found we may need $ is scavro interop, but that’s actually using different mangling strategy: list of keywords, and here calling avro-compiler.

So in this PR instead I switched to mangling by backticks, and doing that only on scala keywords, as we don’t need to do that on Java keywords.

I didn’t test thorougly scavro part but everything still looks OK, and it fixes my problem.

(edit: Also #85 would be fixed)

Happy to hear your feedback.

Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

apache kafka - Getting Illegal initial character: in schema parsing
I guess, the problem is, you are using a dot (.) in name field(connect.name). Which is not allowed . Take a look at...
Read more >
org.apache.avro.SchemaParseException Java Examples
This page shows Java code examples of org.apache.avro. ... c == '_')) { throw new SchemaParseException("Illegal character in: " + name + "...
Read more >
org.apache.avro.SchemaParseException java code examples
Best Java code snippets using org.apache.avro. ... origin: apache/avro ... throw new SchemaParseException("Illegal character in: "+name); } return name; }.
Read more >
Getting Illegal character error while building job
Getting below error while building job. org.talend.commons.exception.PersistenceException: org.apache.avro.SchemaParseException: Illegal ...
Read more >
Solved: NiFi SchemaParseException: Illegal initial charact...
when using the MergeContent processor I'm getting an avro.SchemaParseException due to $ characters in a nested attribute name ($.Snapshot.
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