temporalio/temporal · error
history is nil
Error message
history is nil
What it means
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.
Source
Thrown at common/testing/taskpoller/taskpoller.go:368
}
if req.TaskQueue == nil {
req.TaskQueue = opts.tv.TaskQueue()
}
if req.Identity == "" {
req.Identity = opts.tv.WorkerIdentity()
}
resp, err := p.client.PollWorkflowTaskQueue(ctx, req)
if err != nil {
return nil, err
}
if resp == nil || resp.TaskToken == nil {
return nil, NoWorkflowTaskAvailable
}
var events []*historypb.HistoryEvent
history := resp.History
if history == nil {
return nil, errors.New("history is nil")
}
events = history.Events
if len(events) == 0 && req.TaskQueue.GetKind() != enumspb.TASK_QUEUE_KIND_STICKY {
return nil, errors.New("history events are empty")
}
nextPageToken := resp.NextPageToken
for nextPageToken != nil {
resp, err := p.client.GetWorkflowExecutionHistory(
ctx,
&workflowservice.GetWorkflowExecutionHistoryRequest{
Namespace: p.namespace,
Execution: resp.WorkflowExecution,
NextPageToken: nextPageToken,
})
if err != nil {
return nil, errView on GitHub (pinned to bde624efd1)
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
Example fix
// before resp, _ := poller.Poll(...) // fake client returns empty response // after resp, _ := poller.Poll(...) require.NotNil(t, resp.History) require.NotEmpty(t, resp.History.Events)
Defensive patterns
Strategy: validation
Validate before calling
if resp == nil || resp.History == nil {
return errors.New("poll response has no history")
} Try / catch
task, err := poller.PollForWorkflowTask(...)
if err != nil {
// includes "history is nil"; inspect mock client's PollWorkflowTaskQueueResponse
} Prevention
- Populate History in fake frontend responses
- Start the workflow before polling
- Use require.NotNil(t, resp.History) before dispatching
When it happens
Trigger: PollWorkflowTask/withHeaders returns a response whose History field is nil — typically a stubbed/fake client returning an empty PollWorkflowTaskQueueResponse, or an unexpected server response.
Common situations: 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.
Related errors
- missing RespondWorkflowTaskCompletedRequest return
- history events are empty
- missing PollWorkflowTaskQueueResponse
- missing Legacy Query in PollWorkflowTaskQueueResponse
- missing RespondQueryTaskCompletedRequest
AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01).
Data as JSON: /api/errors/b79f3e6585fcad3f.
Report an issue: GitHub.