{"record":{"id":"48b5153058825e20","repo":"apache/beam","slug":"mismatched-restriction-type-in-method-v-parameter-at-index-v","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":1015,"sourceCode":"\trestrictionT := fn.methods[createInitialRestrictionName].Ret[0].T\n\trTrackerT := reflect.TypeOf((*sdf.RTracker)(nil)).Elem()\n\n\tfor _, name := range requiredSdfNames {\n\t\tmethod := fn.methods[name]\n\t\tstartIdx := sdfRequiredParamStartIndex(method)\n\n\t\tswitch name {\n\t\tcase createInitialRestrictionName:\n\t\t\tif err := validateSdfElementT(fn, createInitialRestrictionName, method, num, startIdx); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase splitRestrictionName:\n\t\t\tif err := validateSdfElementT(fn, splitRestrictionName, method, num, startIdx); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tidx := num + startIdx\n\t\t\tif method.Param[idx].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\tsplitRestrictionName, idx, method.Param[idx].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\tsplitRestrictionName, idx, method.Param[idx].T, restrictionT, createInitialRestrictionName)\n\t\t\t}\n\t\t\tif method.Ret[0].T.Kind() != reflect.Slice ||\n\t\t\t\tmethod.Ret[0].T.Elem() != restrictionT {\n\t\t\t\terr := errors.Errorf(\"invalid output type in method %v, return %v. got: %v, want: %v\",\n\t\t\t\t\tsplitRestrictionName, 0, method.Ret[0].T, reflect.SliceOf(restrictionT))\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. Got: %v, Want: %v (from method %v). \"+\n\t\t\t\t\t\"Ensure that all restrictions in an SDF are the same type, and that %v returns a slice.\",\n\t\t\t\t\tsplitRestrictionName, 0, method.Ret[0].T, reflect.SliceOf(restrictionT), createInitialRestrictionName, splitRestrictionName)\n\t\t\t}\n\t\tcase restrictionSizeName:\n\t\t\tif err := validateSdfElementT(fn, restrictionSizeName, method, num, startIdx); err != nil {\n\t\t\t\treturn err","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L997-L1033","documentation":"In SplitRestriction, the restriction parameter's type must exactly equal the restriction type produced by CreateInitialRestriction. This error (raised from validateSdfSignatures for splitRestrictionName) fires when reflect type identity fails between the SplitRestriction param at the restriction position and the restriction type from CreateInitialRestriction.","triggerScenarios":"SplitRestriction accepting a differently named/typed restriction struct or an interface instead of the concrete restriction type returned by CreateInitialRestriction.","commonSituations":"Defining two similar restriction types (e.g. rangeTracker vs offsetRange) across files; using a generic or alias type; copying an SDF and renaming the restriction only in some methods.","solutions":["Make SplitRestriction's restriction parameter exactly the same concrete type returned by CreateInitialRestriction.","Remove any interface or wrapper type around the restriction parameter; use the concrete restriction struct.","Unify duplicate restriction type definitions into one shared type.","Check for named-type vs underlying-type mismatches (reflection requires exact type identity)."],"exampleFix":"// before\nfunc (fn *myFn) SplitRestriction(r otherRestriction) (truncIntRange, error) { ... }\n\n// after\nfunc (fn *myFn) SplitRestriction(r truncIntRange) ([]truncIntRange, error) { ... }","handlingStrategy":"validation","validationCode":"// Assert restriction type identity across SDF methods:\nfunc checkRestrictionTypes(t reflect.Type) error {\n    cir, _ := t.MethodByName(\"CreateInitialRestriction\")\n    sr, _ := t.MethodByName(\"SplitRestriction\")\n    want := cir.Type.Out(0)\n    // SplitRestriction: receiver + optional ctx + element(s) + restriction\n    got := sr.Type.In(sr.Type.NumIn() - 1)\n    if got != want {\n        return fmt.Errorf(\"SplitRestriction restriction %v != CreateInitialRestriction %v\", got, want)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define the restriction type once and reference it in every SDF method","Avoid interfaces/pointers around restriction types","Grep all SDF methods for the restriction type name after refactors"],"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-14T16:17:12.679Z"}