Open
Description
I am working on converting some contracts from using Avro4s to Vulcan. Because they are existing contracts I am constrained in what I can do---I am attempting to produce precisely equivalent Avro before and after.
I've hit a case that's giving me trouble. The following is a MWE.
import vulcan.*
final case class Foo(bar: Option[Int])
object Foo {
implicit lazy val codec: Codec[Foo] =
Codec.record(
name = "Foo",
namespace = "com.example",
)(field =>
field(
"bar",
_.bar,
default = Some(Some(1337)),
).map(Foo.apply)
)
}
This results in a Foo.codec.schema
which is a Left
containing
vulcan.AvroException$$anon$1: org.apache.avro.AvroTypeException: Invalid default for field bar: 1337 not a ["null","int"]
In my example, I was using an enum, not an integer, and got the same behavior. I noticed that Some(None)
works as a default, but this does not match my existing contracts.
Metadata
Metadata
Assignees
Labels
No labels