{"record":{"id":"777a540fa9a2b85f","repo":"temporalio/temporal","slug":"batchparams-is-nil","errorCode":null,"errorMessage":"batchParams is nil","messagePattern":"batchParams is nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/batcher/workflow.go","lineNumber":140,"sourceCode":"\nvar (\n\tbatchActivityRetryPolicy = temporal.RetryPolicy{\n\t\tInitialInterval:    10 * time.Second,\n\t\tBackoffCoefficient: 1.7,\n\t\tMaximumInterval:    5 * time.Minute,\n\t}\n\n\tbatchActivityOptions = workflow.ActivityOptions{\n\t\tScheduleToStartTimeout: 5 * time.Minute,\n\t\tStartToCloseTimeout:    infiniteDuration,\n\t\tRetryPolicy:            &batchActivityRetryPolicy,\n\t}\n)\n\n// BatchWorkflowProtobuf is the workflow that runs a batch job of resetting workflows.\nfunc BatchWorkflowProtobuf(ctx workflow.Context, batchParams *batchspb.BatchOperationInput) (HeartBeatDetails, error) {\n\tif batchParams == nil {\n\t\treturn HeartBeatDetails{}, errors.New(\"batchParams is nil\")\n\t}\n\n\tbatchParams = setDefaultParams(batchParams)\n\tbatchActivityOptions.HeartbeatTimeout = batchParams.ActivityHeartbeatTimeout.AsDuration()\n\topt := workflow.WithActivityOptions(ctx, batchActivityOptions)\n\tvar result HeartBeatDetails\n\tvar ac *activities\n\terr := workflow.ExecuteActivity(opt, ac.BatchActivityWithProtobuf, batchParams).Get(ctx, &result)\n\tif err != nil {\n\t\treturn HeartBeatDetails{}, err\n\t}\n\n\terr = attachBatchOperationStats(ctx, result)\n\tif err != nil {\n\t\treturn HeartBeatDetails{}, err\n\t}\n\treturn result, err\n}","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/batcher/workflow.go#L122-L158","documentation":"BatchWorkflowProtobuf is the entry workflow for batch operations (reset, terminate, signal, delete-namespace) and expects its input as a *batchspb.BatchOperationInput serialized in the workflow start payload. If the parameter is nil — the workflow was started with no input, a nil payload, or an older/incorrect input type — it immediately fails with this error since no batch can run without parameters.","triggerScenarios":"Starting the batch workflow (BatchWorkflowProtobuf / temporal batch operations) with an empty or malformed input payload, or programmatically executing the workflow passing nil for batchParams.","commonSituations":"Calling temporal batch operations against a server/CLI version mismatch where the input proto isn't populated; hand-crafted workflow start via SDK with wrong input type; replaying old executions with a different input encoding.","solutions":["Start the batch operation through the CLI (`temporal batch ...`) or SDK helper that serializes BatchOperationInput correctly.","Verify the input payload is present and of type batchspb.BatchOperationInput when starting the workflow manually.","Check CLI/server version compatibility — old CLIs may omit fields newer workflow code expects.","If it's a genuine bug path, treat the nil check as a precondition and fix the caller that starts the workflow without input."],"exampleFix":"// before\ntemporalClient.ExecuteWorkflow(ctx, opts, batcher.BatchWorkflowProtobuf, nil)\n// after\ninput := &batchspb.BatchOperationInput{\n\tQuery: \"ExecutionStatus = \\\"Running\\\"\",\n\tOperation: &batchspb.BatchOperationInput_ResetOperation{...},\n}\ntemporalClient.ExecuteWorkflow(ctx, opts, batcher.BatchWorkflowProtobuf, input)","handlingStrategy":"validation","validationCode":"if batchParams == nil || batchParams.Operation == nil {\n\treturn fmt.Errorf(\"batch operation input must be a non-nil batchspb.BatchOperationInput with an operation\")\n}","typeGuard":"func isValidBatchInput(p *batchspb.BatchOperationInput) bool {\n\treturn p != nil && p.Operation != nil\n}","tryCatchPattern":"wf, err := temporalClient.ExecuteWorkflow(ctx, opts, batcher.BatchWorkflowProtobuf, input)\nif err != nil {\n\t// input serialization failure or immediate validation error like \"batchParams is nil\"\n}","preventionTips":["Always start batch workflows via the CLI or SDK helpers that serialize BatchOperationInput.","Pin CLI/server versions so input protos match the workflow code's expectations.","Unit-test batch workflow starts with a populated BatchOperationInput."],"tags":["batch","workflow-input","go","validation"],"backgroundTag":"missing-workflow-input","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}