{"record":{"id":"e6f2574cca20c432","repo":"hashicorp/terraform","slug":"s-canceled-e6f257","errorCode":null,"errorMessage":"%s canceled.","messagePattern":"(.+?) canceled\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/cloud/backend_common.go","lineNumber":316,"sourceCode":"\t\t\t\tif i > 0 {\n\t\t\t\t\telapsed = fmt.Sprintf(\n\t\t\t\t\t\t\" (%s elapsed)\", current.Sub(started).Truncate(30*time.Second))\n\t\t\t\t}\n\t\t\t\tb.CLI.Output(b.Colorize().Color(\"[bold]\" + msgPrefix + \":\\n\"))\n\t\t\t\tb.CLI.Output(b.Colorize().Color(\"Waiting for cost estimate to complete...\" + elapsed + \"\\n\"))\n\t\t\t}\n\t\t\tcontinue\n\t\tcase tfe.CostEstimateSkippedDueToTargeting:\n\t\t\tb.CLI.Output(b.Colorize().Color(\"[bold]\" + msgPrefix + \":\\n\"))\n\t\t\tb.CLI.Output(\"Not available for this plan, because it was created with the -target option.\")\n\t\t\tb.CLI.Output(\"\\n------------------------------------------------------------------------\")\n\t\t\treturn nil\n\t\tcase tfe.CostEstimateErrored:\n\t\t\tb.CLI.Output(msgPrefix + \" errored.\\n\")\n\t\t\tb.CLI.Output(\"\\n------------------------------------------------------------------------\")\n\t\t\treturn nil\n\t\tcase tfe.CostEstimateCanceled:\n\t\t\treturn fmt.Errorf(\"%s canceled.\", msgPrefix)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"Unknown or unexpected cost estimate state: %s\", ce.Status)\n\t\t}\n\t}\n}\n\nfunc (b *Cloud) checkPolicy(stopCtx, cancelCtx context.Context, op *backendrun.Operation, r *tfe.Run) error {\n\tif b.CLI != nil {\n\t\tb.CLI.Output(\"\\n------------------------------------------------------------------------\\n\")\n\t}\n\tfor i, pc := range r.PolicyChecks {\n\t\t// Read the policy check logs. This is a blocking call that will only\n\t\t// return once the policy check is complete.\n\t\tlogs, err := b.client.PolicyChecks.Logs(stopCtx, pc.ID)\n\t\tif err != nil {\n\t\t\treturn b.generalError(\"Failed to retrieve policy check logs\", err)\n\t\t}\n\t\treader := bufio.NewReaderSize(logs, 64*1024)","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend_common.go#L298-L334","documentation":"During the cost-estimation polling loop, the run's CostEstimate entered tfe.CostEstimateCanceled—someone or something (user, admin, or an auto-cancel policy) aborted the cost estimate. The backend converts this into a fatal error for the run rather than continuing silently.","triggerScenarios":"ce.Status transitions to tfe.CostEstimateCanceled while the backend polls the cost estimate. Triggered by a user clicking Cancel in the UI, a run being discarded, or an org-level policy auto-canceling runs.","commonSituations":"Operator manually cancels a long cost estimate; another teammate discards the run from the UI while CI is waiting; CI timeout in the upstream orchestrator sends a cancel request to TFE.","solutions":["Re-trigger the run and avoid canceling it from the UI mid-flight.","Disable cost estimation for the workspace if it consistently times out.","Coordinate CI and operators so only one source controls a run's lifecycle."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := b.checkCostEstimation(ctx, op, r); err != nil {\n    if strings.Contains(err.Error(), \"canceled\") {\n        // surface to user / re-trigger the run\n        return retryRun(r.ID)\n    }\n    return err\n}","preventionTips":["Coordinate so only one actor (CI or operator) controls a run's lifecycle.","Disable cost estimation on workspaces where it consistently gets canceled.","Watch the run in the UI when long cost estimates are expected."],"tags":["tfe","hcp","cloud-backend","cost-estimation","canceled"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}