Skip to content

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

@iamrajiv

Description

@iamrajiv

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions