{"record":{"id":"07b015591d1524c0","repo":"hashicorp/terraform","slug":"unknown-or-unexpected-cost-estimate-state-s","errorCode":null,"errorMessage":"Unknown or unexpected cost estimate state: %s","messagePattern":"Unknown or unexpected cost estimate state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote/backend_common.go","lineNumber":368,"sourceCode":"\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)\n\n\t\t// Retrieve the policy check to get its current status.","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote/backend_common.go#L350-L386","documentation":"The default branch of costEstimate()'s status switch: the cost-estimate returned a status string not matched by any known case (Finished, Pending, Queued, SkippedDueToTargeting, Errored, Canceled). This indicates the go-tfe client / terraform version is out of date relative to the server, which introduced a new cost-estimate status.","triggerScenarios":"A newer HCP Terraform / TFE server returns a CostEstimate status value that this build of terraform's switch statement doesn't know about; the value is rendered via %s in the message.","commonSituations":"Terraform CLI is older than the TFE/HCP server which added a new cost-estimate lifecycle state; using a self-hosted TFE on a newer version than the bundled go-tfe supports.","solutions":["Upgrade your terraform CLI to the latest version so its status enum matches the server.","Upgrade/patch the self-hosted TFE install to a version compatible with your CLI, or vice-versa.","Report the unknown status value (shown in the message) if it persists on the latest CLI."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"var knownCostStatuses = map[tfe.CostEstimateStatus]bool{\n    tfe.CostEstimateFinished: true, tfe.CostEstimatePending: true,\n    tfe.CostEstimateQueued: true, tfe.CostEstimateErrored: true,\n    tfe.CostEstimateCanceled: true, tfe.CostEstimateSkippedDueToTargeting: true,\n}\nfunc isKnownCostStatus(s tfe.CostEstimateStatus) bool { return knownCostStatuses[s] }","tryCatchPattern":null,"preventionTips":["Keep terraform CLI on the latest release to match new server-side statuses.","Align self-hosted TFE and CLI versions.","Report unknown statuses that persist on the latest CLI as a bug."],"tags":["cost-estimate","version","compatibility"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}