{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend_common.go#L300-L336","documentation":"Cost-estimate state switch hit its default: ce.Status is a value not present in the enumerated tfe.CostEstimate* constants known to this binary. Almost always a client/server version skew—the TFE server returned a newer status string the client doesn't recognize.","triggerScenarios":"ce.Status is set by the server to a value outside {Pending, Queued, Starting, Running, Finished, Errored, Canceled, SkippedDueToTargeting, ...}. Happens when a newer TFE server introduces a new status and the client predates it.","commonSituations":"OpenTofu/Terraform binary built against an older tfe SDK hitting a freshly upgraded TFE; preview features adding intermediate states; rarely a corrupted/empty status field.","solutions":["Upgrade the Terraform/OpenTofu binary to a version whose bundled tfe SDK knows the new status.","Downgrade the TFE server side temporarily if upgrade is not possible.","Report the unknown status value (visible in %s) to confirm it is a real enum and not corruption."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func knownCostEstimateStatus(s tfe.CostEstimateStatus) bool {\n    switch s {\n    case tfe.CostEstimatePending, tfe.CostEstimateQueued, tfe.CostEstimateStarting,\n         tfe.CostEstimateRunning, tfe.CostEstimateFinished, tfe.CostEstimateErrored,\n         tfe.CostEstimateCanceled, tfe.CostEstimateSkippedDueToTargeting:\n        return true\n    }\n    return false\n}","typeGuard":"func isKnownCostEstimateStatus(s tfe.CostEstimateStatus) bool {\n    return s >= tfe.CostEstimatePending && s <= tfe.CostEstimateSkippedDueToTargeting\n}","tryCatchPattern":null,"preventionTips":["Keep the Terraform/OpenTofu binary aligned with the TFE server version.","Check the tfe SDK changelog when upgrading TFE.","Log the raw status string so unknown values are diagnosable."],"tags":["tfe","hcp","cloud-backend","cost-estimation","version-compat"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}