{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote/backend_common.go#L350-L386","documentation":"Default branch of the cost-estimate status switch. The TFE API returned a ce.Status value that does not match any known tfe.CostEstimate* constant. This indicates the server and client disagree on the set of possible statuses, almost always a version-skew problem.","triggerScenarios":"ce.Status is not Pending/Queued/Started/Finished/Errored/Canceled/SkippedDueToTargeting. Happens when a newer TFE/TFC introduces a cost-estimate status the running Terraform client does not recognize.","commonSituations":"TFE upgraded ahead of the Terraform CLI; using a very old CLI against a new TFC; beta/preview cost-estimation features emitting new statuses; mismatched terraform and tfe Go library versions in a custom build.","solutions":["Upgrade the Terraform CLI to a version at least as recent as the TFE/TFC deployment.","If you cannot upgrade the CLI, pin TFE to a compatible version until the CLI can be updated.","Report the unknown status string to Terraform maintainers if it persists on a current CLI."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Fail fast if client and server versions are incompatible.\nfunc ensureCompatible(tfeVersion, cliVersion string) error {\n    if semverCompare(tfeVersion) > semverCompare(cliVersion) {\n        return fmt.Errorf(\"TFE/TFC newer than CLI; upgrade Terraform to avoid unknown cost-estimate states\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Terraform CLI version >= the TFE/TFC version to avoid unrecognized statuses.","Pin versions in lockstep in CI matrices.","When TFE is upgraded, schedule a CLI upgrade in the same change window."],"tags":["backend","remote-backend","cost-estimation","version-skew","unknown-state","go"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}