apache/beam · error
panic: %v %s
Error message
panic: %v %s
What it means
CallNoPanic invokes a reflectx Func but converts any Go panic raised during the call into an error instead of crashing. The error message embeds the recovered panic value plus the full debug stack trace.
Source
Thrown at sdks/go/pkg/beam/core/util/reflectx/call.go:125
func (f *namedFunc) Name() string { return f.name }
func (f *namedFunc) Type() reflect.Type { return f.inner.Type() }
func (f *namedFunc) Call(args []any) []any { return f.inner.Call(args) }
// Interface returns the original unwrapped function, which
// runtime.RegisterFunction needs for pointer extraction.
func (f *namedFunc) Interface() any {
if rf, ok := f.inner.(*reflectFunc); ok {
return rf.fn.Interface()
}
return nil
}
// CallNoPanic calls the given Func and catches any panic.
func CallNoPanic(fn Func, args []any) (ret []any, err error) {
defer func() {
if r := recover(); r != nil {
err = errors.Errorf("panic: %v %s", r, debug.Stack())
}
}()
return fn.Call(args), nil
}
// ValueOf performs a per-element reflect.ValueOf.
func ValueOf(list []any) []reflect.Value {
ret := make([]reflect.Value, len(list))
for i := 0; i < len(list); i++ {
ret[i] = reflect.ValueOf(list[i])
}
return ret
}
// Interface performs a per-element Interface call.
func Interface(list []reflect.Value) []any {
ret := make([]any, len(list))
for i := 0; i < len(list); i++ {View on GitHub (pinned to 12126d8942)
Solutions
- Read the debug.Stack() portion of the error to find the panicking frame in your function
- Add nil checks / bounds checks inside the user function that panicked
- Fix the registered function's signature to match the expected Func (correct number/types of args)
Example fix
// before
func myDoFn(s string) string { return s[:3] }
// after
func myDoFn(s string) string {
if len(s) < 3 { return s } // guard against slice-bounds panic
return s[:3]
} Defensive patterns
Strategy: try-catch
Try / catch
ret, err := reflectx.CallNoPanic(fn, args)
if err != nil {
log.Printf("function panicked: %v", err) // error already embeds debug.Stack()
return err
} Prevention
- Nil-check element values inside DoFns before slicing/mapping them
- Verify registered function signatures match the expected Func arity and types
- Prefer returning errors over panicking inside user pipeline functions
When it happens
Trigger: Any fn.Call(args) that panics: nil map/slice access, nil pointer dereference, type assertion failure, index out of range inside user-registered DoFn/function code invoked via CallNoPanic.
Common situations: User DoFns with nil elements in a PCollection, mismatched function signatures registered into the pipeline, or map lookups on nil maps inside element-processing functions.
Related errors
- panicked: %v
- err
- invoker: %v has > 5 return values, which is not permitted
- illegal re-iter type: %v
- illegal iter type: %v
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/d61821ddb5112f6c.
Report an issue: GitHub.