{"record":{"id":"c5b87a51bc5f6ec4","repo":"hashicorp/terraform","slug":"s-hard-failed-c5b87a","errorCode":null,"errorMessage":"%s hard failed.","messagePattern":"(.+?) hard failed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_common.go","lineNumber":395,"sourceCode":"\t\t\t\t\tline = append(line, l...)\n\t\t\t\t}\n\n\t\t\t\tif next || len(line) > 0 {\n\t\t\t\t\tb.CLI.Output(b.Colorize().Color(string(line)))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tswitch pc.Status {\n\t\tcase tfe.PolicyPasses:\n\t\t\tif (r.HasChanges && op.Type == backendrun.OperationTypeApply || i < len(r.PolicyChecks)-1) && b.CLI != nil {\n\t\t\t\tb.CLI.Output(\"\\n------------------------------------------------------------------------\")\n\t\t\t}\n\t\t\tcontinue\n\t\tcase tfe.PolicyErrored:\n\t\t\treturn fmt.Errorf(\"%s errored.\", msgPrefix)\n\t\tcase tfe.PolicyHardFailed:\n\t\t\treturn fmt.Errorf(\"%s hard failed.\", msgPrefix)\n\t\tcase tfe.PolicySoftFailed:\n\t\t\trunURL := fmt.Sprintf(runHeaderErr, b.Hostname, b.Organization, op.Workspace, r.ID)\n\n\t\t\tif op.Type == backendrun.OperationTypePlan || op.UIOut == nil || op.UIIn == nil ||\n\t\t\t\t!pc.Actions.IsOverridable || !pc.Permissions.CanOverride {\n\t\t\t\treturn fmt.Errorf(\"%s soft failed.\\n%s\", msgPrefix, runURL)\n\t\t\t}\n\n\t\t\tif op.AutoApprove {\n\t\t\t\tif _, err = b.client.PolicyChecks.Override(stopCtx, pc.ID); err != nil {\n\t\t\t\t\treturn b.generalError(fmt.Sprintf(\"Failed to override policy check.\\n%s\", runURL), err)\n\t\t\t\t}\n\t\t\t} else if !b.input {\n\t\t\t\treturn errPolicyOverrideNeedsUIConfirmation\n\t\t\t} else {\n\t\t\t\topts := &terraform.InputOpts{\n\t\t\t\t\tId:          \"override\",\n\t\t\t\t\tQuery:       \"\\nDo you want to override the soft failed policy check?\",","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend_common.go#L377-L413","documentation":"Policy check entered tfe.PolicyHardFailed: a hard-failed policy is a non-overridable enforcement that blocks the run regardless of permissions. The message names the policy stage (msgPrefix) but offers no override path, by design.","triggerScenarios":"pc.Status == tfe.PolicyHardFailed: an 'advisory'/'mandatory' (hard) policy evaluated to false on a non-overridable policy set; admin marked the policy enforcement level as hard-mandatory.","commonSituations":"Production guardrail policy (e.g. 'no public S3 buckets') correctly blocks an unsafe plan; policy enforcement level was raised from soft to hard by an admin; new mandatory policy added org-wide.","solutions":["Read the policy violation output to identify which rule failed and fix the plan accordingly.","If the violation is intentional/exception, request an admin adjust the policy or its enforcement level.","Do not attempt to override—hard-failed policies are non-overridable by design."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// preview hard-mandatory policy failures during plan, before apply\nfunc previewHardPolicies(client *tfe.Client, org, ws string) error {\n    sets, err := client.PolicySets.List(ctx, org, nil)\n    if err != nil { return err }\n    for _, ps := range sets.Items {\n        if ps.EnforcementLevel == \"hard-mandatory\" {\n            // ensure plan satisfies before apply; this is a reminder hook\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat hard-mandatory policies as non-negotiable; fix the plan instead of trying to override.","Run `terraform plan` first to see policy violations before apply.","Document which policies are hard-mandatory per workspace."],"tags":["tfe","hcp","cloud-backend","policy","sentinel","hard-mandatory"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}