{"record":{"id":"35374b6894cb392c","repo":"hashicorp/terraform","slug":"errdestroydiscarded","errorCode":"errDestroyDiscarded","errorMessage":"Destroy discarded.","messagePattern":"Destroy discarded\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"internal/cloud/errors.go","lineNumber":18,"sourceCode":"// Copyright IBM Corp. 2014, 2026\n// SPDX-License-Identifier: BUSL-1.1\n\npackage cloud\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/hashicorp/terraform/internal/tfdiags\"\n\t\"github.com/zclconf/go-cty/cty\"\n)\n\n// String based errors\nvar (\n\terrApplyDiscarded                    = errors.New(\"Apply discarded.\")\n\terrDestroyDiscarded                  = errors.New(\"Destroy discarded.\")\n\terrRunApproved                       = errors.New(\"approved using the UI or API\")\n\terrRunDiscarded                      = errors.New(\"discarded using the UI or API\")\n\terrRunOverridden                     = errors.New(\"overridden using the UI or API\")\n\terrApplyNeedsUIConfirmation          = errors.New(\"Cannot confirm apply due to -input=false. Please handle run confirmation in the UI.\")\n\terrPolicyOverrideNeedsUIConfirmation = errors.New(\"Cannot override soft failed policy checks when -input=false. Please open the run in the UI to override.\")\n)\n\n// Diagnostic error messages\nvar (\n\tinvalidWorkspaceConfigMissingValues = tfdiags.AttributeValue(\n\t\ttfdiags.Error,\n\t\t\"Invalid workspaces configuration\",\n\t\tfmt.Sprintf(\"Missing workspace mapping strategy. Either workspace \\\"tags\\\" or \\\"name\\\" is required.\\n\\n%s\", workspaceConfigurationHelp),\n\t\tcty.Path{cty.GetAttrStep{Name: \"workspaces\"}},\n\t)\n\n\tinvalidWorkspaceConfigMisconfiguration = tfdiags.AttributeValue(\n\t\ttfdiags.Error,","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/errors.go#L1-L36","documentation":"Returned by the Terraform Cloud backend when a destroy run is discarded before it executes. Analogous to errApplyDiscarded but specific to destroy-mode operations (op.PlanMode == plans.DestroyMode). Set in backend_common.go:492-493 when the discarded run was a destroy operation.","triggerScenarios":"Running 'terraform destroy' against a cloud-backed workspace and declining the destroy confirmation prompt, or having the destroy run discarded externally via UI/API while the CLI waits. backend_common.go:492 checks op.PlanMode == plans.DestroyMode to select this error over errApplyDiscarded.","commonSituations":"An operator cancels a destructive destroy at the last-second confirmation; a teammate discards the run in TFC UI; automation sends a Discard API call during a destroy.","solutions":["Re-run 'terraform destroy' if the discard was unintentional.","If discarding was intentional, no further action is needed.","Use -auto-approve with destroy to bypass the interactive confirmation in automated contexts.","Ensure no concurrent UI/API discard operations run alongside CLI destroy commands."],"exampleFix":"// before\nterraform destroy\n// user types 'no' -> Destroy discarded.\n\n// after\nterraform destroy -auto-approve","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// if errors.Is(err, cloud.ErrDestroyDiscarded) {\n//     log.Info(\"destroy was discarded by user or externally\")\n//     return nil\n// }","preventionTips":["Use -auto-approve for non-interactive destroy operations.","Prevent concurrent operations on shared cloud workspaces during destroy.","Distinguish discard from genuine errors in CI pipeline exit-code handling."],"tags":["terraform","cloud","destroy","run-lifecycle","confirmation"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}