{"record":{"id":"7320662f1181f875","repo":"hashicorp/terraform","slug":"unknown-or-unexpected-policy-state-s-732066","errorCode":null,"errorMessage":"Unknown or unexpected policy state: %s","messagePattern":"Unknown or unexpected policy state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_common.go","lineNumber":435,"sourceCode":"\t\t\t\tif err != nil && err != errRunOverridden {\n\t\t\t\t\treturn fmt.Errorf(\"Failed to override: %w\\n%s\\n\", err, runURL)\n\t\t\t\t}\n\n\t\t\t\tif err != errRunOverridden {\n\t\t\t\t\tif _, err = b.client.PolicyChecks.Override(stopCtx, pc.ID); err != nil {\n\t\t\t\t\t\treturn b.generalError(fmt.Sprintf(\"Failed to override policy check.\\n%s\", runURL), err)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trunURL := fmt.Sprintf(runHeader, b.Hostname, b.Organization, op.Workspace, r.ID)\n\t\t\t\t\tb.CLI.Output(fmt.Sprintf(\"The run needs to be manually overridden or discarded.\\n%s\\n\", runURL))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif b.CLI != nil {\n\t\t\t\tb.CLI.Output(\"------------------------------------------------------------------------\")\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"Unknown or unexpected policy state: %s\", pc.Status)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (b *Cloud) confirm(stopCtx context.Context, op *backendrun.Operation, opts *terraform.InputOpts, r *tfe.Run, keyword string) error {\n\tdoneCtx, cancel := context.WithCancel(stopCtx)\n\tresult := make(chan error, 2)\n\n\tgo func() {\n\t\t// Make sure we cancel doneCtx before we return\n\t\t// so the input command is also canceled.\n\t\tdefer cancel()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-doneCtx.Done():","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_common.go#L417-L453","documentation":"The default case of the policy-check status switch (backend_common.go:435). Returned when pc.Status does not match any handled tfe.Policy* constant (Passes, Errored, HardFailed, SoftFailed, plus the early-continue Pending/Queued/Unreachable). Indicates client/server version skew: the server reported a policy lifecycle state the local go-tfe library does not recognize.","triggerScenarios":"After streaming logs, pc.Status is an unrecognized value in the switch at backend_common.go:386-435. The TFE/HCP server is newer than the bundled go-tfe constants.","commonSituations":"Older Terraform CLI against a newer HCP Terraform / TFE that introduced a new policy status. Unstable/server-side preview features.","solutions":["Upgrade the local Terraform CLI so its go-tfe dependency knows the new status.","Align the TFE server version with a release compatible with your CLI.","Report the unknown status string shown in the error if versions are current."],"exampleFix":"// before: stale CLI\n// -> Unknown or unexpected policy state: \"queued_post_override\"\n// after: upgrade CLI\nterraform version  # then upgrade to latest stable","handlingStrategy":"validation","validationCode":"func knownPolicyStatus(s tfe.PolicyStatus) bool {\n    switch s {\n    case tfe.PolicyPasses, tfe.PolicyErrored, tfe.PolicyHardFailed,\n         tfe.PolicySoftFailed, tfe.PolicyPending, tfe.PolicyQueued, tfe.PolicyUnreachable:\n        return true\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Terraform CLI aligned with the HCP/TFE server version.","Avoid pre-release server policy features with a stable CLI."],"tags":["terraform","tfe","policy","version-skew","cloud-backend"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}