Root Cause
The canAssignVMType function in analyze.go does not handle the case where a union contains
a recursive/self-referencing record type. When NestedProperty references itself inside
the union's value type, the analyzer encounters a nil pointer because the type has not
been fully resolved yet during the schema tree walk.
Key Details
- The schema is valid per the Avro specification. Recursive types via named references are
explicitly allowed.
- The panic occurs during schema parsing (ParseType), not during marshal/unmarshal.
- The panic occurs regardless of the Go target struct — even if the Go struct has no
corresponding field for the problematic schema field, the full schema tree is still
analyzed.
- Schemas with simple unions (e.g., ["null", "string"]) or non-recursive records work
fine. The issue is specifically with recursive named type references inside multi-branch
unions.
Expected Behavior
avro.ParseType() should either:
- Successfully parse the schema and handle recursive type references during analysis, OR
- Return an error describing the unsupported pattern (instead of panicking)
Root Cause
The canAssignVMType function in analyze.go does not handle the case where a union contains
a recursive/self-referencing record type. When NestedProperty references itself inside
the union's value type, the analyzer encounters a nil pointer because the type has not
been fully resolved yet during the schema tree walk.
Key Details
explicitly allowed.
corresponding field for the problematic schema field, the full schema tree is still
analyzed.
fine. The issue is specifically with recursive named type references inside multi-branch
unions.
Expected Behavior
avro.ParseType() should either: