{"record":{"id":"d717db58fa0e362e","repo":"apache/beam","slug":"v-method-has-no-main-inputs","errorCode":null,"errorMessage":"%v method has no main inputs","messagePattern":"(.+?) method has no main inputs","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":661,"sourceCode":"\terr = validateTimer(doFn, numMainIn)\n\tif err != nil {\n\t\treturn nil, addContext(err, fn)\n\t}\n\n\treturn doFn, nil\n}\n\n// validateMainInputs checks that a method has the given number of main inputs\n// and that main inputs are before any side inputs.\nfunc validateMainInputs(fn *Fn, method *funcx.Fn, methodName string, numMainIn mainInputs) error {\n\tif numMainIn == MainUnknown {\n\t\tnumMainIn = MainSingle // If unknown, validate for minimum number of inputs.\n\t}\n\n\t// Make sure there are enough inputs (at least numMainIn)\n\tpos, num, ok := method.Inputs()\n\tif !ok {\n\t\terr := errors.Errorf(\"%v method has no main inputs\", methodName)\n\t\terr = errors.SetTopLevelMsgf(err,\n\t\t\t\"Method %v in DoFn %v is missing all inputs. A main input is required.\",\n\t\t\tmethodName, fn.Name())\n\t\treturn err\n\t}\n\tif num < int(numMainIn) {\n\t\terr := errors.Errorf(\"%v method has too few main inputs\", methodName)\n\t\terr = errors.SetTopLevelMsgf(err,\n\t\t\t\"Method %v in DoFn %v does not have enough main inputs. \"+\n\t\t\t\t\"%v main inputs were expected, but only %v inputs were found.\",\n\t\t\tmethodName, fn.Name(), numMainIn, num)\n\t\treturn err\n\t}\n\n\t// Check that the first input is not an Iter or ReIter (those aren't valid\n\t// as the first main input).\n\tfirst := method.Param[pos].Kind\n\tif first != funcx.FnValue {","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L643-L679","documentation":"Error returned by validateMainInputs when method.Inputs() reports zero usable inputs for the method being validated (with numMainIn unknown defaulting to MainSingle). It means the DoFn method (e.g. ProcessElement or @OnTimer) declares no main input parameters at all, so the signature cannot satisfy even the minimum single-main-input requirement.","triggerScenarios":"Defining ProcessElement with only a context and/or emit functions but no main input parameter, e.g. ProcessElement(ctx context.Context, emit func(string)).","commonSituations":"Writing a generator-style DoFn expecting to emit without consuming input; accidental deletion of the element parameter during refactoring.","solutions":["Add a main input parameter to ProcessElement matching the PCollection element type","If source-like behavior is intended, use a beam.Impulse + root transform instead of a DoFn without input","Check the InputType/numMainIn configuration when using multi-input DoFns"],"exampleFix":"// before\nfunc (f *MyFn) ProcessElement(emit func(int)) { ... }\n// after\nfunc (f *MyFn) ProcessElement(ctx context.Context, s string, emit func(int)) { ... }","handlingStrategy":"validation","validationCode":"m, _ := reflect.TypeOf(fn).MethodByName(\"ProcessElement\")\nif m != (reflect.Method{}) && m.Type.NumIn() < 3 { // recv + (ctx) + main input\n  return errors.New(\"ProcessElement must declare a main input parameter\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the element parameter in ProcessElement","Use beam.Impulse-based sources instead of input-free DoFns"],"tags":["go","apache-beam","dofn","process-element"],"backgroundTag":"missing-required-argument","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"}