{"record":{"id":"220da315f247dfa2","repo":"hashicorp/terraform","slug":"unknown-or-unexpected-cost-estimate-state-s-220da3","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/cloud/backend_common.go","lineNumber":318,"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(\"[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)\n\n\t\t// Retrieve the policy check to get its current status.","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_common.go#L300-L336","documentation":"The default case of the cost-estimate status switch (backend_common.go:318). It fires when ce.Status does not match any of the handled tfe.CostEstimate* constants (Finished, Pending, Queued, SkippedDueToTargeting, Errored, Canceled). This indicates a client/server version skew where the server emitted a new status value the local go-tfe library does not understand.","triggerScenarios":"The TFE/HCP server is newer than the bundled go-tfe constants in the local Terraform binary, returning a cost-estimate status string outside the known set. Encountered mid-poll in the switch at backend_common.go:265.","commonSituations":"Using an older Terraform CLI against a much newer HCP Terraform / TFE that introduced a new cost-estimate lifecycle state. Pre-release/unstable server features.","solutions":["Upgrade the local Terraform CLI to a version whose go-tfe dependency recognizes the new status.","Downgrade or stabilize the TFE server to a release compatible with your CLI.","Report the unknown status string (in the error message) to Terraform maintainers if versions are current."],"exampleFix":"// before: terraform 1.5.x against bleeding-edge HCP Terraform\n// -> Unknown or unexpected cost estimate state: \"custom_state\"\n// after: upgrade CLI\nterraform version  # confirm, then upgrade to latest stable","handlingStrategy":"validation","validationCode":"// Guard against unknown statuses by pinning compatible versions.\nfunc knownCostEstimateStatus(s tfe.CostEstimateStatus) bool {\n    switch s {\n    case tfe.CostEstimateFinished, tfe.CostEstimatePending, tfe.CostEstimateQueued,\n         tfe.CostEstimateSkippedDueToTargeting, tfe.CostEstimateErrored, tfe.CostEstimateCanceled:\n        return true\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Terraform CLI version current relative to the HCP/TFE server.","Avoid mixing pre-release server builds with stable CLI versions."],"tags":["terraform","tfe","cost-estimation","version-skew","cloud-backend"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}