apache/beam · error
mismatched watermark state type in method
Error message
mismatched watermark state type in method %v, return value at index %v got: %v, want: %v (from method %v). Ensure that all watermark states in an SDF are the same type.
What it means
WatermarkEstimatorState's sole parameter must be exactly the sdf.WatermarkEstimator interface type. Beam validates method.Param[0].T against watermarkEstimatorT and throws this error when the parameter is a different type, since it passes the constructed estimator to this method.
Solutions
- Change the parameter type to sdf.WatermarkEstimator and type-assert inside to your concrete estimator.
- Ensure CreateWatermarkEstimator returns a value assignable to sdf.WatermarkEstimator so the round trip type-checks.
- If you intended a state-parameter method, that's InitialWatermarkEstimatorState / CreateWatermarkEstimator — fix the method name instead.
- Follow the canonical stateful SDF example so all watermark method signatures stay consistent.
Example fix
// before
func (f *fn) WatermarkEstimatorState(st myState) myState { return st }
// after
func (f *fn) WatermarkEstimatorState(we sdf.WatermarkEstimator) myState {
return we.(*myWatermarkEstimator).state
} Defensive patterns
Strategy: type-guard
Validate before calling
var _ func(sdf.WatermarkEstimator) myState = (*fn).WatermarkEstimatorState
Type guard
func asWatermarkEstimator(v any) (sdf.WatermarkEstimator, bool) {
we, ok := v.(sdf.WatermarkEstimator)
return we, ok
} Prevention
- The parameter must be the sdf.WatermarkEstimator interface, not the state struct.
- Type-assert to your concrete estimator inside the method body.
- Keep estimator (object) and state (value) concepts distinct when writing signatures.
When it happens
Trigger: Declaring WatermarkEstimatorState(state myState) (reading state directly instead of the estimator); using a concrete estimator type or pointer where Beam expects the sdf.WatermarkEstimator interface parameter.
Common situations: Confusing the estimator object with the estimator state in the signature; writing the state-extraction method to take the state struct instead; following outdated or inconsistent examples.
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
- mismatched event time type in method
- mismatched output type in method
- Invalid output type in method
- Invalid output type in method
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/e0e5d2e0a7913466.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/graph/fn.go:1320
if method.Ret[0].T != watermarkStateT {
err := errors.Errorf("mismatched output type in method %v, return %v. got: %v, want: %v",
createWatermarkEstimatorName, 0, method.Ret[0].T, watermarkStateT)
return errors.SetTopLevelMsgf(err, "mismatched output type in method %v, "+
"return value at index %v got: %v, want: %v (from method %v). "+
"Ensure that all watermark states in an SDF are the same type.",
createWatermarkEstimatorName, 0, method.Ret[0].T, watermarkStateT, createWatermarkEstimatorName)
}
case watermarkEstimatorStateName:
if len(method.Param) != 1 {
err := errors.Errorf("unexpected number of params in method %v. got: %v, want %v",
watermarkEstimatorStateName, len(method.Param), 1)
return errors.SetTopLevelMsgf(err, "unexpected number of parameters in method %v. "+
"got: %v, want %v. Check that the signature conforms to the expected signature for %v, "+
"and that elements in SDF method parameters match elements in %v.",
watermarkEstimatorStateName, len(method.Param), 1, watermarkEstimatorStateName, processElementName)
}
if method.Param[0].T != watermarkEstimatorT {
err := errors.Errorf("mismatched watermark state type in method %v, return %v. got: %v, want: %v",
watermarkEstimatorStateName, 0, method.Param[0].T, watermarkEstimatorT)
return errors.SetTopLevelMsgf(err, "mismatched watermark state type in method %v, "+
"return value at index %v got: %v, want: %v (from method %v). "+
"Ensure that all watermark states in an SDF are the same type.",
watermarkEstimatorStateName, 0, method.Param[0].T, watermarkEstimatorT, watermarkEstimatorStateName)
}
if len(method.Ret) != 1 {
err := errors.Errorf("unexpected number of elements returned in method %v. got: %v, want %v",
watermarkEstimatorStateName, len(method.Ret), 1)
return errors.SetTopLevelMsgf(err, "unexpected number of elements returned in method %v. "+
"got: %v, want %v. Check that the signature conforms to the expected signature for %v.",
watermarkEstimatorStateName, len(method.Ret), 1, watermarkEstimatorStateName)
}
if method.Ret[0].T != watermarkStateT {
err := errors.Errorf("mismatched output type in method %v, return %v. got: %v, want: %v",
watermarkEstimatorStateName, 0, method.Ret[0].T, watermarkStateT)
return errors.SetTopLevelMsgf(err, "mismatched output type in method %v, "+
"return value at index %v got: %v, want: %v (from method %v). "+View on GitHub (pinned to 12126d8942)