{"record":{"id":"66d5128e5cfa5c79","repo":"temporalio/temporal","slug":"getworkflowexecutionhistory-failed","errorCode":null,"errorMessage":"GetWorkflowExecutionHistory failed","messagePattern":"GetWorkflowExecutionHistory failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/worker/batcher/activities.go","lineNumber":1130,"sourceCode":"\nfunc getFirstWorkflowTaskEventID(\n\tctx context.Context,\n\tnamespaceStr string,\n\tworkflowExecution *commonpb.WorkflowExecution,\n\tfrontendClient workflowservice.WorkflowServiceClient,\n\tlogger log.Logger,\n) (workflowTaskEventID int64, err error) {\n\treq := &workflowservice.GetWorkflowExecutionHistoryRequest{\n\t\tNamespace:       namespaceStr,\n\t\tExecution:       workflowExecution,\n\t\tMaximumPageSize: 1000,\n\t\tNextPageToken:   nil,\n\t}\n\tfor {\n\t\tresp, err := frontendClient.GetWorkflowExecutionHistory(ctx, req)\n\t\tif err != nil {\n\t\t\tlogger.Error(\"failed to run GetWorkflowExecutionHistory\", tag.Error(err))\n\t\t\treturn 0, errors.New(\"GetWorkflowExecutionHistory failed\")\n\t\t}\n\t\tfor _, e := range resp.GetHistory().GetEvents() {\n\t\t\tswitch e.GetEventType() {\n\t\t\tcase enumspb.EVENT_TYPE_WORKFLOW_TASK_COMPLETED:\n\t\t\t\tworkflowTaskEventID = e.GetEventId()\n\t\t\t\treturn workflowTaskEventID, nil\n\t\t\tcase enumspb.EVENT_TYPE_WORKFLOW_TASK_SCHEDULED:\n\t\t\t\tif workflowTaskEventID == 0 {\n\t\t\t\t\tworkflowTaskEventID = e.GetEventId() + 1\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif len(resp.NextPageToken) == 0 {\n\t\t\tbreak\n\t\t}\n\t\treq.NextPageToken = resp.NextPageToken\n\t}\n\tif workflowTaskEventID == 0 {","sourceCodeStart":1112,"sourceCodeEnd":1148,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/worker/batcher/activities.go#L1112-L1148","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Search worker logs for 'failed to run GetWorkflowExecutionHistory' to find the root cause.","Confirm the workflow's history is retrievable (not archived/purged) with temporal workflow show --workflow-id ...","Check frontend/history service health and database connectivity.","Re-run the batch operation after restoring service health; consider paginating smaller batches to reduce load."],"exampleFix":"// before\nresp, err := frontendClient.GetWorkflowExecutionHistory(ctx, req)\nif err != nil {\n\tlogger.Error(\"failed to run GetWorkflowExecutionHistory\", tag.Error(err))\n\treturn 0, errors.New(\"GetWorkflowExecutionHistory failed\")\n}\n// after\nresp, err := frontendClient.GetWorkflowExecutionHistory(ctx, req)\nif err != nil {\n\tlogger.Error(\"failed to run GetWorkflowExecutionHistory\", tag.Error(err))\n\treturn 0, fmt.Errorf(\"GetWorkflowExecutionHistory failed: %w\", err)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := batcher.GetFirstWorkflowTaskEventID(...); err != nil {\n\tif strings.Contains(err.Error(), \"GetWorkflowExecutionHistory failed\") {\n\t\t// retry with backoff after checking history service health\n\t}\n}","preventionTips":["Check that target workflows' history is retrievable (not archived/deleted) before batch resets.","Run batch jobs during low-traffic windows to reduce history RPC pressure.","Keep batcher client configuration (frontend address, namespace) up to date."],"tags":["batch","history","rpc","go"],"backgroundTag":"history-rpc-failed","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}