{"record":{"id":"0e9b948448736b99","repo":"apache/beam","slug":"mismatched-restriction-type-in-method-v-parameter-at-index-v-0e9b94","errorCode":null,"errorMessage":"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.","messagePattern":"mismatched restriction type in method (.+?), parameter at index (.+?)\\. got: (.+?), want: (.+?) \\(from method (.+?)\\)\\. Ensure that all restrictions 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":1284,"sourceCode":"\t\tswitch name {\n\t\tcase initialWatermarkEstimatorStateName:\n\t\t\tif len(method.Param) != numMainIn+2 {\n\t\t\t\terr := errors.Errorf(\"unexpected number of params in method %v. got: %v, want: %v\",\n\t\t\t\t\tinitialWatermarkEstimatorStateName, len(method.Param), numMainIn+2)\n\t\t\t\treturn errors.SetTopLevelMsgf(err, \"unexpected number of parameters 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\t\"and that elements in SDF method parameters match elements in %v.\",\n\t\t\t\t\tinitialWatermarkEstimatorStateName, len(method.Param), numMainIn+2, initialWatermarkEstimatorStateName, processElementName)\n\t\t\t}\n\t\t\tif method.Param[0].T != typex.EventTimeType {\n\t\t\t\terr := errors.Errorf(\"unexpected parameter type in method %v, param %v. got: %v, want: %v\",\n\t\t\t\t\tinitialWatermarkEstimatorStateName, 0, method.Param[0].T, typex.EventTimeType)\n\t\t\t\treturn errors.SetTopLevelMsgf(err, \"mismatched event time type in method %v, \"+\n\t\t\t\t\t\"parameter at index %v. got: %v, want: %v.\",\n\t\t\t\t\tinitialWatermarkEstimatorStateName, 0, method.Param[0].T, typex.EventTimeType)\n\t\t\t}\n\t\t\tif method.Param[1].T != restT {\n\t\t\t\terr := errors.Errorf(\"mismatched restriction type in method %v, param %v. got: %v, want: %v\",\n\t\t\t\t\tinitialWatermarkEstimatorStateName, 1, method.Param[1].T, restT)\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\tinitialWatermarkEstimatorStateName, 1, method.Param[1].T, restT, createTrackerName)\n\t\t\t}\n\t\t\tif err := validateSdfElementT(fn, initialWatermarkEstimatorStateName, method, numMainIn, 2); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\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\tinitialWatermarkEstimatorStateName, 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\tinitialWatermarkEstimatorStateName, len(method.Ret), 1, initialWatermarkEstimatorStateName)\n\t\t\t}\n\t\t\tif method.Ret[0].T != watermarkStateT {","sourceCodeStart":1266,"sourceCodeEnd":1302,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L1266-L1302","documentation":"All SDF restriction-bearing methods must share one restriction type. Beam validates that InitialWatermarkEstimatorState's restriction parameter (index 1) exactly equals the restriction type produced by CreateInitialRestriction (and used by CreateTracker). A mismatch fails validation with this error, which names the reference method that established the expected type.","triggerScenarios":"Declaring InitialWatermarkEstimatorState with a restriction type different from the one CreateInitialRestriction returns / CreateTracker takes — e.g. a same-named struct in another package, a pointer where others use a value, or a differently parameterized generic restriction.","commonSituations":"Creating an alias or duplicate restriction struct during refactoring so methods no longer share the identical named type; switching value vs pointer restriction types in some methods; copy-pasting methods between SDFs with same-named but distinct restriction types.","solutions":["Use the exact same named restriction type (as produced by CreateInitialRestriction and consumed by CreateTracker) in InitialWatermarkEstimatorState.","Eliminate duplicate/same-named restriction types in different packages; pick one canonical type.","Make value/pointer usage consistent across all restriction-bearing methods.","Check for aliases or generics resolving to different underlying named types across methods."],"exampleFix":"// before\nfunc (f *fn) CreateTracker(rest MyRestriction) sdf.SdfBasicTracker { ... }\nfunc (f *fn) InitialWatermarkEstimatorState(rt typex.EventTime, rest *MyRestriction) myState { ... }\n// after\nfunc (f *fn) CreateTracker(rest MyRestriction) sdf.SdfBasicTracker { ... }\nfunc (f *fn) InitialWatermarkEstimatorState(rt typex.EventTime, rest MyRestriction) myState { ... }","handlingStrategy":"validation","validationCode":"// One canonical restriction type for the whole SDF\ntype MyRestriction struct{ Start, End int64 }\nvar _ func(MyRestriction) sdf.SdfBasicTracker = (*fn).CreateTracker\nvar _ func(string, typex.EventTime, MyRestriction) myState = (*fn).InitialWatermarkEstimatorState","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define the restriction type once and reference it everywhere; never create aliases or duplicates.","Be consistent about value vs pointer for the restriction across all methods.","A compile-time assertion on CreateTracker's signature propagates the canonical type."],"tags":["go","apache-beam","sdf","restriction","type-mismatch"],"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"}