{"record":{"id":"40cf03e8b88cd0c6","repo":"apache/beam","slug":"number-of-side-inputs-in-method-v-does-not-match-method-v","errorCode":null,"errorMessage":"number of side inputs in method %v does not match method %v: got %d, expected %d","messagePattern":"number of side inputs in method (.+?) does not match method (.+?): got (.+?), expected (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":766,"sourceCode":"\tnumSideIn := numProcessIn - int(numMainIn)\n\tposMethodIn, numMethodIn, ok := method.Inputs()\n\n\t// Handle cases where method has no inputs.\n\tif !ok {\n\t\tif numSideIn == 0 { // We're good, expected no side inputs.\n\t\t\treturn nil\n\t\t}\n\t\t// Error, missing side inputs.\n\t\terr := errors.Errorf(\"side inputs expected in method %v\", methodName)\n\t\treturn errors.SetTopLevelMsgf(err,\n\t\t\t\"Missing side inputs in the %v method of a DoFn. \"+\n\t\t\t\t\"If side inputs are present in %v those side inputs must also be present in %v.\",\n\t\t\tmethodName, processElementName, methodName)\n\t}\n\n\t// Error if number of side inputs doesn't match.\n\tif numMethodIn != numSideIn {\n\t\terr := errors.Errorf(\"number of side inputs in method %v does not match method %v: got %d, expected %d\",\n\t\t\tmethodName, processElementName, numMethodIn, numSideIn)\n\t\treturn errors.SetTopLevelMsgf(err,\n\t\t\t\"Incorrect number of side inputs in the %v method of a DoFn. \"+\n\t\t\t\t\"The side inputs should match those of the %v method.\",\n\t\t\tmethodName, processElementName)\n\t}\n\n\t// Error if there's a type mismatch.\n\tmethodInputs := method.Param[posMethodIn : posMethodIn+numMethodIn]\n\tsideInputs := processFnInputs[numMainIn:] // Skip main inputs in ProcessFn\n\tfor i := 0; i < len(sideInputs); i++ {\n\t\tif sideInputs[i].T != methodInputs[i].T {\n\t\t\tvar err error = &funcx.TypeMismatchError{Got: methodInputs[i].T, Want: sideInputs[i].T}\n\t\t\terr = errors.Wrapf(err, \"side input in method %v does not match side input in %v\",\n\t\t\t\tmethodName, processElementName)\n\t\t\treturn errors.SetTopLevelMsgf(err,\n\t\t\t\t\"Incorrect side inputs in the %v method of a DoFn. \"+\n\t\t\t\t\t\"The side inputs should match those of the %v method.\",","sourceCodeStart":748,"sourceCodeEnd":784,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L748-L784","documentation":"validateSideInputs requires a DoFn auxiliary method's input count (after main inputs) to equal the number of side inputs in ProcessElement. This error is thrown from AsDoFn when the auxiliary method declares a different number of side-input parameters than ProcessElement provides.","triggerScenarios":"A StartBundle/FinishBundle method declaring fewer or more side input parameters than the beam.ParDo call supplies (e.g. one side input at the call site, two in the method), during AsDoFn conversion.","commonSituations":"Adding another beam.SideInput to the ParDo call without updating DoFn methods; removing a side input from ProcessElement but leaving it in FinishBundle; count mismatch after refactoring multi-input transforms.","solutions":["Align the auxiliary method's side input parameter count with ProcessElement's side inputs.","Update the beam.ParDo call to pass exactly the number of side inputs the DoFn methods declare.","Keep types aligned too, otherwise error 4904 follows."],"exampleFix":"// before\nfunc (fn *myFn) ProcessElement(w string, a beam.V, b beam.V) {}\nfunc (fn *myFn) StartBundle(a beam.V) {}\n\n// after\nfunc (fn *myFn) ProcessElement(w string, a beam.V, b beam.V) {}\nfunc (fn *myFn) StartBundle(a beam.V, b beam.V) {}","handlingStrategy":"validation","validationCode":"// verify side input count parity before building:\nif numSideInputsInParDo != countSideInputParams(doFnMethods) {\n\treturn fmt.Errorf(\"side input count mismatch\")\n}","typeGuard":"func countSideInputParams(m reflect.Method) int { return m.Type.NumIn() - baseParams(m) }","tryCatchPattern":"err := beam.ParDo(s, fn, in, beam.SideInput{...}); if err != nil { log.Fatalf(\"side input mismatch: %v\", err) }","preventionTips":["When adding/removing a side input, update ProcessElement and all auxiliary methods together","Comment the expected signature shape at the top of the DoFn","Keep a golden unit test that registers every DoFn"],"tags":["go","apache-beam","dofn","side-input","signature-validation"],"backgroundTag":"schema-validation-failed","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"}