temporalio/temporal · error

GetWorkflowExecutionHistory failed

Error message

GetWorkflowExecutionHistory failed

What it means

getFirstWorkflowTaskEventID pages forward through a workflow's history via GetWorkflowExecutionHistory to locate the first WorkflowTaskCompleted event for batch reset. Any RPC failure is logged and replaced by this generic sentinel error. Like its reverse counterpart, the underlying cause is lost from the returned error and must be read from the worker logs.

Source

Thrown at service/worker/batcher/activities.go:1130

func getFirstWorkflowTaskEventID(
	ctx context.Context,
	namespaceStr string,
	workflowExecution *commonpb.WorkflowExecution,
	frontendClient workflowservice.WorkflowServiceClient,
	logger log.Logger,
) (workflowTaskEventID int64, err error) {
	req := &workflowservice.GetWorkflowExecutionHistoryRequest{
		Namespace:       namespaceStr,
		Execution:       workflowExecution,
		MaximumPageSize: 1000,
		NextPageToken:   nil,
	}
	for {
		resp, err := frontendClient.GetWorkflowExecutionHistory(ctx, req)
		if err != nil {
			logger.Error("failed to run GetWorkflowExecutionHistory", tag.Error(err))
			return 0, errors.New("GetWorkflowExecutionHistory failed")
		}
		for _, e := range resp.GetHistory().GetEvents() {
			switch e.GetEventType() {
			case enumspb.EVENT_TYPE_WORKFLOW_TASK_COMPLETED:
				workflowTaskEventID = e.GetEventId()
				return workflowTaskEventID, nil
			case enumspb.EVENT_TYPE_WORKFLOW_TASK_SCHEDULED:
				if workflowTaskEventID == 0 {
					workflowTaskEventID = e.GetEventId() + 1
				}
			}
		}
		if len(resp.NextPageToken) == 0 {
			break
		}
		req.NextPageToken = resp.NextPageToken
	}
	if workflowTaskEventID == 0 {

View on GitHub (pinned to bde624efd1)

Solutions

  1. Search worker logs for 'failed to run GetWorkflowExecutionHistory' to find the root cause.
  2. Confirm the workflow's history is retrievable (not archived/purged) with temporal workflow show --workflow-id ...
  3. Check frontend/history service health and database connectivity.
  4. Re-run the batch operation after restoring service health; consider paginating smaller batches to reduce load.

Example fix

// before
resp, err := frontendClient.GetWorkflowExecutionHistory(ctx, req)
if err != nil {
	logger.Error("failed to run GetWorkflowExecutionHistory", tag.Error(err))
	return 0, errors.New("GetWorkflowExecutionHistory failed")
}
// after
resp, err := frontendClient.GetWorkflowExecutionHistory(ctx, req)
if err != nil {
	logger.Error("failed to run GetWorkflowExecutionHistory", tag.Error(err))
	return 0, fmt.Errorf("GetWorkflowExecutionHistory failed: %w", err)
}
Defensive patterns

Strategy: retry

Try / catch

if _, err := batcher.GetFirstWorkflowTaskEventID(...); err != nil {
	if strings.Contains(err.Error(), "GetWorkflowExecutionHistory failed") {
		// retry with backoff after checking history service health
	}
}

Prevention

When it happens

Trigger: Running a batch reset that needs the first workflow-task event ID while GetWorkflowExecutionHistory fails: frontend unreachable, persistence errors, nonexistent workflow/run, or unauthorized namespace access.

Common situations: Batch reset of workflows whose history has been deleted or archived; history service overload during large batch jobs; stale client connection after cluster membership change; wrong namespace in batch filter.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/66d5128e5cfa5c79. Report an issue: GitHub.