heetch / heetch/avro

panic: runtime error: invalid memory address or nil pointer dereference

Open
#148 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
95
Forks
18
PR merge metrics
No merged PRs in 30d

Description

## 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:
1. Successfully parse the schema and handle recursive type references during analysis, OR
2. Return an error describing the unsupported pattern (instead of panicking)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.