{"record":{"id":"cc049afadde28bd0","repo":"hashicorp/terraform","slug":"s-canceled","errorCode":null,"errorMessage":"%s canceled.","messagePattern":"(.+?) canceled\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote/backend_common.go","lineNumber":366,"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(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(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 *Remote) 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 generalError(\"Failed to retrieve policy check logs\", err)\n\t\t}\n\t\treader := bufio.NewReaderSize(logs, 64*1024)","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote/backend_common.go#L348-L384","documentation":"In costEstimate(), when the cost-estimate sub-resource's status becomes tfe.CostEstimateCanceled. This means the cost estimation was canceled (typically because the parent run was canceled via the UI or API while estimation was pending/queued), so the polling loop returns this error to abort the operation.","triggerScenarios":"costEstimate() polls CostEstimates.Read; ce.Status == tfe.CostEstimateCanceled. Usually the parent run was discarded/canceled by a user or automation in the HCP/TFE UI while cost estimation was still running.","commonSituations":"Someone clicked 'Discard run' or canceled via API during a plan that includes cost estimation; a run exceeded a timeout and was auto-canceled; concurrent operations where one cancel cascades.","solutions":["Re-run the plan/apply — the cancellation was external and the next run will get a fresh cost estimate.","Avoid canceling runs in the UI while a local CLI stream is attached.","If cancellations are automated, review the automation triggering them."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isCostCanceled(s tfe.CostEstimateStatus) bool {\n    return s == tfe.CostEstimateCanceled\n}","tryCatchPattern":"if err := b.costEstimate(stopCtx, cancelCtx, op, r); err != nil {\n    if strings.Contains(err.Error(), \"canceled\") {\n        // external cancel of cost estimate -> surface, invite re-run\n    }\n    return err\n}","preventionTips":["Avoid canceling runs in the UI while a CLI stream is attached.","Review automation that auto-discards queued runs.","Document that a canceled cost estimate requires re-running the plan."],"tags":["cost-estimate","run","canceled"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}