apache/beam · error

nil type at index

Error message

nil type at index: %v

What it means

checkTypesNotNil is a pre-check run inside typex.New on the component list; it panics if any FullType in the list is a nil interface. This fails fast with the offending index instead of producing a corrupt type tree or a confusing nil-pointer panic later.

Solutions

  1. Inspect the reported index and fix the component list so every element is a non-nil typex.FullType before calling New.
  2. Check errors from any type-resolution function used to build the components instead of discarding the nil result.
  3. Pre-validate with a loop that skips/aborts on nil entries before constructing the type.

Example fix

// before
cs := []typex.FullType{keyT, valT}
cs[1] = resolveT(name) // may return nil, error ignored
typex.New(typex.KVType, cs...)
// after
t, err := resolveT(name)
if err != nil { return err }
cs := []typex.FullType{keyT, t}
typex.New(typex.KVType, cs...)
Defensive patterns

Strategy: validation

Validate before calling

func allNotNil(cs []typex.FullType) bool {
    for _, c := range cs { if c == nil { return false } }
    return true
}

Type guard

func isNilFullType(t typex.FullType) bool { return t == nil }

Try / catch

func safeNew(t typex.Type, cs ...typex.FullType) (ft typex.FullType, err error) {
    defer func() {
        if r := recover(); r != nil { err = fmt.Errorf("typex.New: %v", r) }
    }()
    return typex.New(t, cs...), nil
}

Prevention

When it happens

Trigger: Calling typex.New (or any helper that funnels into it: Prefix, CoGroupByKey, CombinePerKey, CombineGlobally, Flatten, GroupByKey) with a slice containing a nil FullType at position i, e.g. typex.New(typex.KVType, keyType, nil) or passing an uninitialized []typex.FullType element.

Common situations: Building component lists dynamically with append and leaving zero-value entries; failed lookups (functions returning nil FullType on error whose error return was ignored) then fed into New; struct fields of type typex.FullType never initialized.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/6fb7492174404201. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/typex/fulltype.go:455

	}
}

func substituteList(list []FullType, m map[string]reflect.Type) ([]FullType, error) {
	var ret []FullType
	for _, elm := range list {
		repl, err := substitute(elm, m)
		if err != nil {
			return nil, err
		}
		ret = append(ret, repl)
	}
	return ret, nil
}

func checkTypesNotNil(list []FullType) {
	for i, t := range list {
		if t == nil {
			panic(fmt.Sprintf("nil type at index: %v", i))
		}
	}
}

// NoFiringPane return PaneInfo assigned as NoFiringPane(0x0f)
func NoFiringPane() PaneInfo {
	return PaneInfo{IsFirst: true, IsLast: true, Timing: PaneUnknown}
}

View on GitHub (pinned to 12126d8942)