{"record":{"id":"97cac4834d975eaa","repo":"apache/beam","slug":"mismatched-output-type-in-method-v-return-value-at-index-v","errorCode":null,"errorMessage":"Mismatched output type in method %v, return value at index %v. Got: %v, Want: %v (from method %v).","messagePattern":"Mismatched output type in method (.+?), return value at index (.+?)\\. Got: (.+?), Want: (.+?) \\(from method (.+?)\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":1070,"sourceCode":"\t\t\tif method.Param[startIdx].T != restrictionT {\n\t\t\t\terr := errors.Errorf(\"mismatched restriction type in method %v, param %v. got: %v, want: %v\",\n\t\t\t\t\tcreateTrackerName, startIdx, method.Param[startIdx].T, restrictionT)\n\t\t\t\treturn errors.SetTopLevelMsgf(err, \"Mismatched restriction type in method %v, \"+\n\t\t\t\t\t\"parameter at index %v. Got: %v, Want: %v (from method %v). \"+\n\t\t\t\t\t\"Ensure that all restrictions in an SDF are the same type.\",\n\t\t\t\t\tcreateTrackerName, startIdx, method.Param[startIdx].T, restrictionT, createInitialRestrictionName)\n\t\t\t}\n\t\t\tif !method.Ret[0].T.Implements(rTrackerT) {\n\t\t\t\terr := errors.Errorf(\"invalid output type in method %v, return %v: %v does not implement sdf.RTracker\",\n\t\t\t\t\tcreateTrackerName, 0, method.Ret[0].T)\n\t\t\t\treturn errors.SetTopLevelMsgf(err, \"Invalid output type in method %v, \"+\n\t\t\t\t\t\"return value at index %v (type: %v). Output of method %v must implement sdf.RTracker.\",\n\t\t\t\t\tcreateTrackerName, 0, method.Ret[0].T, createTrackerName)\n\t\t\t}\n\t\t\tprocessFn := fn.methods[processElementName]\n\t\t\tpos, _ := processFn.RTracker()\n\t\t\tif method.Ret[0].T != processFn.Param[pos].T {\n\t\t\t\terr := errors.Errorf(\"mismatched output type in method %v, return %v: got: %v, want: %v\",\n\t\t\t\t\tcreateTrackerName, 0, method.Ret[0].T, processFn.Param[pos].T)\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\tcreateTrackerName, 0, method.Ret[0].T, processFn.Param[pos].T, processElementName)\n\t\t\t}\n\t\t}\n\t}\n\n\trTrackerImplT := fn.methods[createTrackerName].Ret[0].T\n\n\tfor _, name := range optionalSdfNames {\n\t\tmethod, ok := fn.methods[name]\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tstartIdx := sdfRequiredParamStartIndex(method)\n","sourceCodeStart":1052,"sourceCodeEnd":1088,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L1052-L1088","documentation":"The tracker returned by CreateTracker must be the exact same type as the RTracker parameter ProcessElement accepts. This error fires when CreateTracker's return type differs from the tracker parameter type found in ProcessElement, because the framework passes the created tracker directly into ProcessElement.","triggerScenarios":"CreateTracker returning *myTracker while ProcessElement takes an sdf.RTracker interface (or a different concrete tracker type), or the two methods using different concrete tracker implementations.","commonSituations":"Declaring ProcessElement's tracker param as the sdf.RTracker interface instead of the concrete tracker type; refactoring one method to a LockRTracker wrapper and not the other; multiple trackers defined for one DoFn.","solutions":["Make ProcessElement's tracker parameter the exact concrete type returned by CreateTracker.","Avoid using the sdf.RTracker interface as the ProcessElement parameter type; use the concrete tracker type.","If you wrapped the tracker (e.g. LockRTracker) in CreateTracker, use the same wrapper type in ProcessElement.","Compare Got/Want types in the error and align both methods on one tracker type."],"exampleFix":"// before\nfunc (fn *myFn) CreateTracker(r myRestriction) *myTracker { ... }\nfunc (fn *myFn) ProcessElement(t sdf.RTracker, elem string, emit func(string)) error { ... }\n\n// after\nfunc (fn *myFn) CreateTracker(r myRestriction) *myTracker { ... }\nfunc (fn *myFn) ProcessElement(t *myTracker, elem string, emit func(string)) error { ... }","handlingStrategy":"validation","validationCode":"// Assert CreateTracker return type == ProcessElement tracker param type:\nfunc checkTrackerConsistency(t reflect.Type) error {\n    ct, _ := t.MethodByName(\"CreateTracker\")\n    pe, _ := t.MethodByName(\"ProcessElement\")\n    got := ct.Type.Out(0)\n    // find tracker param in ProcessElement (first non-ctx param here)\n    want := pe.Type.In(1)\n    if got != want {\n        return fmt.Errorf(\"CreateTracker returns %v but ProcessElement takes %v\", got, want)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the concrete tracker type (not the sdf.RTracker interface) in ProcessElement","Change CreateTracker and ProcessElement together when changing tracker types","Keep tracker type as a single named type referenced by both methods"],"tags":["go","apache-beam","sdf","type-mismatch","reflection"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}