apache/beam · error
Invalid output type in method
Error message
Invalid output type in method %v, return value at index %v. Got: %v, Want: %v. Sizing information in SDF methods must be in float64.
What it means
RestrictionSize must return a float64 sizing value. This error fires when its first return value is any other type (int, int64, float32, etc.), because the framework requires sizing information to be float64 for consistent bundle sizing.
Solutions
- Change RestrictionSize's return to float64 and convert internally (e.g. float64(len(...))).
- Remove any error return if unneeded, keeping float64 (optionally last error is allowed per count check).
- Update any computed size expressions to produce float64 values.
- Re-run registration to confirm no other SDF method type mismatches remain.
Example fix
// before
func (fn *myFn) RestrictionSize(r myRestriction) int { return len(r.List) }
// after
func (fn *myFn) RestrictionSize(r myRestriction) float64 { return float64(len(r.List)) } Defensive patterns
Strategy: validation
Validate before calling
// Assert RestrictionSize returns float64:
func checkSizeReturn(t reflect.Type) error {
rs, ok := t.MethodByName("RestrictionSize")
if !ok { return nil }
if rs.Type.Out(0) != reflect.TypeOf(float64(0)) {
return fmt.Errorf("RestrictionSize must return float64, got %v", rs.Type.Out(0))
}
return nil
} Prevention
- Always write RestrictionSize as func(...) float64
- Wrap len()/numeric computations in float64() conversions
- Never use float32 for SDF sizing
When it happens
Trigger: Declaring RestrictionSize with return type int, int64, float32, or a custom numeric type instead of float64.
Common situations: Using Go's default numeric literals/len() results (int) as the return; copying code that used float32; minimal-effort ports from other SDKs where sizes are ints.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Invalid output type in method
- invalid output type in method
- mismatched event time type in method
- Mismatched output type in method
- mismatched output type in method
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/d88d16a6af643808.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/graph/fn.go:1045
"return value at index %v. Got: %v, Want: %v (from method %v). "+
"Ensure that all restrictions in an SDF are the same type, and that %v returns a slice.",
splitRestrictionName, 0, method.Ret[0].T, reflect.SliceOf(restrictionT), createInitialRestrictionName, splitRestrictionName)
}
case restrictionSizeName:
if err := validateSdfElementT(fn, restrictionSizeName, method, num, startIdx); err != nil {
return err
}
idx := num + startIdx
if method.Param[idx].T != restrictionT {
err := errors.Errorf("mismatched restriction type in method %v, param %v. got: %v, want: %v",
restrictionSizeName, idx, method.Param[idx].T, restrictionT)
return errors.SetTopLevelMsgf(err, "Mismatched restriction type in method %v, "+
"parameter at index %v. Got: %v, Want: %v (from method %v). "+
"Ensure that all restrictions in an SDF are the same type.",
restrictionSizeName, idx, method.Param[idx].T, restrictionT, createInitialRestrictionName)
}
if method.Ret[0].T != reflectx.Float64 {
err := errors.Errorf("invalid output type in method %v, return %v. got: %v, want: %v",
restrictionSizeName, 0, method.Ret[0].T, reflectx.Float64)
return errors.SetTopLevelMsgf(err, "Invalid output type in method %v, "+
"return value at index %v. Got: %v, Want: %v. Sizing information in SDF methods must be in float64.",
restrictionSizeName, 0, method.Ret[0].T, reflectx.Float64)
}
case createTrackerName:
if method.Param[startIdx].T != restrictionT {
err := errors.Errorf("mismatched restriction type in method %v, param %v. got: %v, want: %v",
createTrackerName, startIdx, method.Param[startIdx].T, restrictionT)
return errors.SetTopLevelMsgf(err, "Mismatched restriction type in method %v, "+
"parameter at index %v. Got: %v, Want: %v (from method %v). "+
"Ensure that all restrictions in an SDF are the same type.",
createTrackerName, startIdx, method.Param[startIdx].T, restrictionT, createInitialRestrictionName)
}
if !method.Ret[0].T.Implements(rTrackerT) {
err := errors.Errorf("invalid output type in method %v, return %v: %v does not implement sdf.RTracker",
createTrackerName, 0, method.Ret[0].T)
return errors.SetTopLevelMsgf(err, "Invalid output type in method %v, "+View on GitHub (pinned to 12126d8942)