You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Templating error: Invalid Schema::Union of only Schema::Null
What I'd expect
A union of only null is an unusual pattern, but it does appear in the wild as a
placeholder field. It might be reasonable to map it to Option<()>, or at least
emit a warning and skip the field gracefully.
Map values of ["string", "null"] could be represented as HashMap<String, Option<String>>.
Notes
These seem to be separate from the previously fixed issue Cannot generate an Optional array #8, which covered ["null", {"type": "array", ...}] and produced a different error message.
For reference, ["null", {"type": "long", "logicalType": "timestamp-millis"}]
(a null-first union with a logical type) works correctly and generates Option<i64> —
so null-first unions in general are fine, just these two specific patterns aren't.
Hi, I ran into two separate cases where rsgen-avro v0.19.3 fails to generate code.
I've minimized them into small repro schemas — hope this helps!
Case 1: Union containing only
nullSchema
{ "type": "record", "name": "Example", "namespace": "com.example", "fields": [ { "name": "only_null", "type": ["null"], "default": null } ] }Error
What I'd expect
A union of only
nullis an unusual pattern, but it does appear in the wild as aplaceholder field. It might be reasonable to map it to
Option<()>, or at leastemit a warning and skip the field gracefully.
Case 2:
nullas a non-first member of map valuesSchema
{ "type": "record", "name": "Example", "namespace": "com.example", "fields": [ { "name": "map_with_null_last", "type": {"type": "map", "values": ["string", "null"]}, "default": {} } ] }Error
What I'd expect
Map values of
["string", "null"]could be represented asHashMap<String, Option<String>>.Notes
["null", {"type": "array", ...}]and produced a different error message.["null", {"type": "long", "logicalType": "timestamp-millis"}](a null-first union with a logical type) works correctly and generates
Option<i64>—so null-first unions in general are fine, just these two specific patterns aren't.
Environment