{"record":{"id":"2b3f0b60ba675d71","repo":"temporalio/temporal","slug":"history-events-are-empty","errorCode":null,"errorMessage":"history events are empty","messagePattern":"history events are empty","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/testing/taskpoller/taskpoller.go","lineNumber":373,"sourceCode":"\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\n\t\t}\n\t\tevents = append(events, resp.History.Events...)\n\t\tnextPageToken = resp.NextPageToken\n\t}\n","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/testing/taskpoller/taskpoller.go#L355-L391","documentation":"pollTask requires at least one history event in the polled workflow task, except when polling a sticky task queue (where incremental/empty histories are legitimate). An empty events list means the server handed back a task whose history contains no events, which the helper cannot dispatch.","triggerScenarios":"PollWorkflowTask response has History != nil but len(History.Events) == 0 while req.TaskQueue.Kind is not TASK_QUEUE_KIND_STICKY.","commonSituations":"Sticky-queue tests forgetting to set Kind: enumspb.TASK_QUEUE_KIND_STICKY on the poll request; mocked client returning a History struct with no events; server-side pagination confusion returning an empty first page.","solutions":["Set TaskQueue.Kind to TASK_QUEUE_KIND_STICKY if this poll targets a sticky queue","Verify the mock/server returns a history containing at least the WorkflowExecutionStarted event","Check pagination handling — the helper fetches further pages via NextPageToken; ensure the first page is non-empty in your fake"],"exampleFix":"// before\nreq.TaskQueue = &taskqueuepb.TaskQueue{Name: tq}\n// after\nreq.TaskQueue = &taskqueuepb.TaskQueue{Name: tq, Kind: enumspb.TASK_QUEUE_KIND_STICKY}","handlingStrategy":"validation","validationCode":"if len(resp.GetHistory().GetEvents()) == 0 &&\n    req.GetTaskQueue().GetKind() != enumspb.TASK_QUEUE_KIND_STICKY {\n    return errors.New(\"poll response history is empty\")\n}","typeGuard":null,"tryCatchPattern":"task, err := poller.PollForWorkflowTask(...)\nif errors.Is(err, errEmptyHistory) || strings.Contains(err.Error(), \"history events are empty\") {\n    // set TASK_QUEUE_KIND_STICKY or fix the mock\n}","preventionTips":["Set Kind: TASK_QUEUE_KIND_STICKY for sticky polls","Ensure the first history page contains the WorkflowExecutionStarted event","Verify mocks return non-empty History.Events"],"tags":["testing","taskpoller","history","sticky-queue"],"backgroundTag":"empty-history-events","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}