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

  1. Change RestrictionSize's return to float64 and convert internally (e.g. float64(len(...))).
  2. Remove any error return if unneeded, keeping float64 (optionally last error is allowed per count check).
  3. Update any computed size expressions to produce float64 values.
  4. 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

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


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)