{"record":{"id":"82cfd7622868537e","repo":"hashicorp/terraform","slug":"errrundiscarded","errorCode":"errRunDiscarded","errorMessage":"discarded using the UI or API","messagePattern":"discarded using the UI or API","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"internal/cloud/errors.go","lineNumber":20,"sourceCode":"// 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,\n\t\t\"Invalid workspaces configuration\",\n\t\tfmt.Sprintf(\"Only one of workspace \\\"tags\\\" or \\\"name\\\" is allowed.\\n\\n%s\", workspaceConfigurationHelp),","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/errors.go#L2-L38","documentation":"A sentinel error set in backend_common.go:468-469 and :476-477 when the cloud backend's polling goroutine detects that a run's status has transitioned to tfe.RunDiscarded during the interactive confirmation wait. Unlike errApplyDiscarded/errDestroyDiscarded (which are user-facing results), this is the intermediate signal that triggers the mapping to those specific errors at backend_common.go:490. It indicates the run was discarded externally via UI/API while the CLI awaited local input.","triggerScenarios":"During a cloud-backed apply or destroy with interactive confirmation active, a teammate or automation system discards the run in the TFC/TFE UI or via the API. The confirm() polling loop in backend_common.go reads the run status, sees RunDiscarded, and sets errRunDiscarded.","commonSituations":"Concurrent operations on a shared workspace; someone cancels a run in the UI while another person's CLI session is waiting for 'yes'; CI/CD automation discards a stale run.","solutions":["Re-run the terraform command if the discard was not intended.","Coordinate workspace access to prevent concurrent UI/API and CLI operations.","Use workspace locks to serialize operations during critical workflows."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// if errors.Is(err, cloud.ErrRunDiscarded) {\n//     log.Info(\"run was discarded externally during confirmation\")\n//     // retry or alert as appropriate\n// }","preventionTips":["Use workspace locks to prevent concurrent operations that lead to external discards.","Monitor for concurrent UI/API operations during CLI-driven workflows.","Set up run notifications in TFC to detect when runs are discarded by others."],"tags":["terraform","cloud","run-lifecycle","confirmation","concurrency"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}