apache/beam · error

panicked: %v

Error message

panicked: %v

What it means

Registry.reconcileRegistrations processes queued types for schema registration inside a locked section. If any registration work panics (reflect panics, nil derefs, etc.), the deferred recover converts the panic into this wrapped error instead of crashing. The error is augmented with context naming the type being reconciled.

Source

Thrown at sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go:120

var sdfRtrackerType = reflect.TypeOf((*sdf.RTracker)(nil)).Elem()

// RegisterType converts the type to it's schema representation, and converts it back to
// a synthetic type so we can map from the synthetic type back to the user type.
// Recursively registers other named struct types in any component parts.
func (r *Registry) RegisterType(ut reflect.Type) {
	r.rwmu.Lock()
	defer r.rwmu.Unlock()
	r.toReconcile = append(r.toReconcile, ut)
}

// reconcileRegistrations actually finishes the registration process.
func (r *Registry) reconcileRegistrations() (deferedErr error) {
	r.rwmu.Lock()
	defer r.rwmu.Unlock()
	var ut reflect.Type
	defer func() {
		if r := recover(); r != nil {
			deferedErr = errors.Errorf("panicked: %v", r)
			deferedErr = errors.WithContextf(deferedErr, "reconciling schema registration for type %v", ut)
		}
	}()
	for _, ut := range r.toReconcile {
		check := func(ut reflect.Type) bool {
			return coder.LookupCustomCoder(ut) != nil
		}
		// We could have either a pointer or non pointer here,
		// so we strip pointerness and then check both.
		vT := reflectx.SkipPtr(ut)
		if check(vT) || check(reflect.PtrTo(vT)) {
			continue
		}
		if err := r.registerType(ut, map[reflect.Type]struct{}{}); err != nil {
			return errors.Wrapf(err, "error reconciling type %v", ut)
		}
	}
	r.toReconcile = nil

View on GitHub (pinned to 12126d8942)

Solutions

  1. Look at the wrapped context to find the type whose reconciliation panicked, then avoid registering that type or fix its custom coder.
  2. Fix the panicking provider/registration function so it returns errors instead of panicking.
  3. Update the Beam SDK if the panic is a known bug in schema reconciliation.

Example fix

// before: registering a type with a panicking custom coder lookup
schema.RegisterType(reflect.TypeOf(myBadType{}))
// after: provide a valid custom coder first
coder.LookupCustomCoder(reflect.TypeOf(myBadType{})) // ensure non-panic, register custom coder
Defensive patterns

Strategy: try-catch

Validate before calling

// validate types before registering
if t.Kind() == reflect.UnsafePointer || t.Kind() == reflect.Chan {
    return errors.New("type not schema-serializable")
}

Try / catch

defer func() {
    if r := recover(); r != nil {
        err = fmt.Errorf("schema registration panicked: %v", r)
    }
}()

Prevention

When it happens

Trigger: Any panic during reconcileRegistrations, e.g. when coder.LookupCustomCoder or registerType panics on a pathological reflect.Type queued via RegisterType/Registered/FromType/ToType.

Common situations: Registering exotic types (unsafe pointers, recursive types) into the schema registry; bugs in custom coders or logical type providers invoked during reconciliation.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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