{"record":{"id":"b79f3e6585fcad3f","repo":"temporalio/temporal","slug":"history-is-nil","errorCode":null,"errorMessage":"history is nil","messagePattern":"history is nil","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/testing/taskpoller/taskpoller.go","lineNumber":368,"sourceCode":"\t}\n\tif req.TaskQueue == nil {\n\t\treq.TaskQueue = opts.tv.TaskQueue()\n\t}\n\tif req.Identity == \"\" {\n\t\treq.Identity = opts.tv.WorkerIdentity()\n\t}\n\tresp, err := p.client.PollWorkflowTaskQueue(ctx, req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp == nil || resp.TaskToken == nil {\n\t\treturn nil, NoWorkflowTaskAvailable\n\t}\n\n\tvar events []*historypb.HistoryEvent\n\thistory := resp.History\n\tif history == nil {\n\t\treturn nil, errors.New(\"history is nil\")\n\t}\n\n\tevents = history.Events\n\tif len(events) == 0 && req.TaskQueue.GetKind() != enumspb.TASK_QUEUE_KIND_STICKY {\n\t\treturn nil, errors.New(\"history events are empty\")\n\t}\n\n\tnextPageToken := resp.NextPageToken\n\tfor nextPageToken != nil {\n\t\tresp, err := p.client.GetWorkflowExecutionHistory(\n\t\t\tctx,\n\t\t\t&workflowservice.GetWorkflowExecutionHistoryRequest{\n\t\t\t\tNamespace:     p.namespace,\n\t\t\t\tExecution:     resp.WorkflowExecution,\n\t\t\t\tNextPageToken: nextPageToken,\n\t\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/testing/taskpoller/taskpoller.go#L350-L386","documentation":"pollTask polls a workflow task and expects the PollWorkflowTaskQueueResponse to carry a History. A nil history means the server returned a task without an execution history, which the test poller treats as unusable. This is a defensive guard so the helper fails with a clear message instead of nil-dereferencing history.Events.","triggerScenarios":"PollWorkflowTask/withHeaders returns a response whose History field is nil — typically a stubbed/fake client returning an empty PollWorkflowTaskQueueResponse, or an unexpected server response.","commonSituations":"Using TaskPoller against a mocked frontend client that forgot to populate resp.History; calling pollTask on a workflow that has not started so no history exists.","solutions":["Ensure the mocked PollWorkflowTaskQueueResponse populates History with at least the WorkflowExecutionStarted event","Verify the workflow is started before polling (StartWorkflow and wait for the first task)","If polling a sticky task queue, set Kind: enumspb.TASK_QUEUE_KIND_STICKY so the empty-history path is allowed"],"exampleFix":"// before\nresp, _ := poller.Poll(...) // fake client returns empty response\n// after\nresp, _ := poller.Poll(...)\nrequire.NotNil(t, resp.History)\nrequire.NotEmpty(t, resp.History.Events)","handlingStrategy":"validation","validationCode":"if resp == nil || resp.History == nil {\n    return errors.New(\"poll response has no history\")\n}","typeGuard":null,"tryCatchPattern":"task, err := poller.PollForWorkflowTask(...)\nif err != nil {\n    // includes \"history is nil\"; inspect mock client's PollWorkflowTaskQueueResponse\n}","preventionTips":["Populate History in fake frontend responses","Start the workflow before polling","Use require.NotNil(t, resp.History) before dispatching"],"tags":["testing","taskpoller","history","nil-argument"],"backgroundTag":"nil-request-in-test-poller","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}