{"record":{"id":"d9c4807006c02a54","repo":"apache/beam","slug":"mismatched-output-type-in-method-v-return-value-at-index-v-d9c480","errorCode":null,"errorMessage":"mismatched output type in method %v, return value at index %v got: %v, want: %v (from method %v). Ensure that all watermark estimators in an SDF are the same type.","messagePattern":"mismatched output type in method (.+?), return value at index (.+?) got: (.+?), want: (.+?) \\(from method (.+?)\\)\\. Ensure that all watermark estimators in an SDF are the same type\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":1335,"sourceCode":"\t\t\t\t\twatermarkEstimatorStateName, len(method.Param), 1, watermarkEstimatorStateName, processElementName)\n\t\t\t}\n\t\t\tif method.Param[0].T != watermarkEstimatorT {\n\t\t\t\terr := errors.Errorf(\"mismatched watermark state type in method %v, return %v. got: %v, want: %v\",\n\t\t\t\t\twatermarkEstimatorStateName, 0, method.Param[0].T, watermarkEstimatorT)\n\t\t\t\treturn errors.SetTopLevelMsgf(err, \"mismatched watermark state type in method %v, \"+\n\t\t\t\t\t\"return value at index %v got: %v, want: %v (from method %v). \"+\n\t\t\t\t\t\"Ensure that all watermark states in an SDF are the same type.\",\n\t\t\t\t\twatermarkEstimatorStateName, 0, method.Param[0].T, watermarkEstimatorT, watermarkEstimatorStateName)\n\t\t\t}\n\t\t\tif len(method.Ret) != 1 {\n\t\t\t\terr := errors.Errorf(\"unexpected number of elements returned in method %v. got: %v, want %v\",\n\t\t\t\t\twatermarkEstimatorStateName, len(method.Ret), 1)\n\t\t\t\treturn errors.SetTopLevelMsgf(err, \"unexpected number of elements returned in method %v. \"+\n\t\t\t\t\t\"got: %v, want %v. Check that the signature conforms to the expected signature for %v.\",\n\t\t\t\t\twatermarkEstimatorStateName, len(method.Ret), 1, watermarkEstimatorStateName)\n\t\t\t}\n\t\t\tif method.Ret[0].T != watermarkStateT {\n\t\t\t\terr := errors.Errorf(\"mismatched output type in method %v, return %v. got: %v, want: %v\",\n\t\t\t\t\twatermarkEstimatorStateName, 0, method.Ret[0].T, watermarkStateT)\n\t\t\t\treturn errors.SetTopLevelMsgf(err, \"mismatched output type in method %v, \"+\n\t\t\t\t\t\"return value at index %v got: %v, want: %v (from method %v). \"+\n\t\t\t\t\t\"Ensure that all watermark estimators in an SDF are the same type.\",\n\t\t\t\t\twatermarkEstimatorStateName, 0, method.Ret[0].T, watermarkStateT, watermarkEstimatorStateName)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateState(fn *DoFn, numIn mainInputs) error {\n\tps := fn.PipelineState()\n\n\tif _, hasSp := fn.methods[processElementName].StateProvider(); hasSp {\n\t\tif numIn == MainSingle {\n\t\t\terr := errors.Errorf(\"ProcessElement uses a StateProvider, but is not keyed\")\n\t\t\treturn errors.SetTopLevelMsgf(err, \"ProcessElement uses a StateProvider, but is not keyed. \"+","sourceCodeStart":1317,"sourceCodeEnd":1353,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L1317-L1353","documentation":"Beam Go validates that every watermark estimator method in a SplittableDoFn returns the same watermark state type. This error fires when a method's single return value's type differs from the watermark state type returned by the other estimator methods (e.g. a different WatermarkEstimator implementation's state type). Beam requires uniformity so state can be serialized and propagated consistently across bundles.","triggerScenarios":"An SDF has multiple watermark-estimator-related methods (e.g. InitialWatermarkEstimatorState and CreateWatermarkEstimatorState) whose return types differ, such as one returning watermark.ManualState and another watermark.State.","commonSituations":"Mixing estimator implementations in one SDF; refactoring one method to a different state type without updating the other; copying methods from two different SDF examples.","solutions":["Make all watermark estimator methods in the SDF return the same watermark state type.","Pick one WatermarkEstimator implementation and use its state type consistently across all methods.","Search the DoFn for all methods taking/returning watermark state and align their types."],"exampleFix":"// before\nfunc (fn *MySDF) InitialWatermarkEstimatorState(et beam.EventTime, rt types.Type) watermark.ManualState { ... }\nfunc (fn *MySDF) CreateWatermarkEstimatorState(s watermark.ManualState) watermark.State { ... }\n// after\nfunc (fn *MySDF) InitialWatermarkEstimatorState(et beam.EventTime, rt types.Type) watermark.State { ... }\nfunc (fn *MySDF) CreateWatermarkEstimatorState(s watermark.State) watermark.State { ... }","handlingStrategy":"validation","validationCode":"// ensure all watermark state types agree\nif reflect.TypeOf(initialRet) != reflect.TypeOf(createRet) {\n    return fmt.Errorf(\"watermark state types differ\")\n}","typeGuard":"func sameStateType(a, b watermark.State) bool { return reflect.TypeOf(a) == reflect.TypeOf(b) }","tryCatchPattern":"if err := beam.Run(ctx, ...); err != nil {\n    if strings.Contains(err.Error(), \"mismatched output type\") {\n        log.Fatalf(\"SDF watermark estimator methods must share one state type: %v\", err)\n    }\n    return err\n}","preventionTips":["Pick one WatermarkEstimator implementation per SDF and stick to it","Grep the DoFn for `watermark.` return types and verify they match","Add a compile-time assertion using a shared named type for all estimator state returns"],"tags":["go","apache-beam","dofn","type-mismatch","watermark"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}