{"record":{"id":"12553fd9bb82a9d8","repo":"hashicorp/terraform","slug":"apply-discarded","errorCode":null,"errorMessage":"Apply discarded.","messagePattern":"Apply discarded\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/backend/remote/backend_common.go","lineNumber":26,"sourceCode":"\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\ttfe \"github.com/hashicorp/go-tfe\"\n\n\t\"github.com/hashicorp/terraform/internal/backend/backendrun\"\n\t\"github.com/hashicorp/terraform/internal/logging\"\n\t\"github.com/hashicorp/terraform/internal/plans\"\n\t\"github.com/hashicorp/terraform/internal/terraform\"\n)\n\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)\n\nvar (\n\tbackoffMin = 1000.0\n\tbackoffMax = 3000.0\n\n\trunPollInterval = 3 * time.Second\n)\n\n// backoff will perform exponential backoff based on the iteration and\n// limited by the provided min and max (in milliseconds) durations.\nfunc backoff(min, max float64, iter int) time.Duration {\n\tbackoff := math.Pow(2, float64(iter)/5) * min\n\tif backoff > max {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote/backend_common.go#L8-L44","documentation":"errApplyDiscarded (internal/backend/remote/backend_common.go:26) is returned by the remote (TFE/TFC) backend's confirm() flow when a run is discarded. It is set when the run transitions to RunDiscarded (line 541) or when the user does not type 'yes' and the run is discarded via the API (line 597). It signals that the apply phase was intentionally aborted, not that it failed technically.","triggerScenarios":"During a remote apply, the user types something other than 'yes' at the confirmation prompt (the run is discarded via Runs.Discard); or the run is discarded through the TFE/TFC UI or API while the CLI is waiting. For destroy operations the parallel errDestroyDiscarded is used instead.","commonSituations":"User typing 'no' or an empty/typo at the apply confirmation in a remote run; a teammate discarding the run from the TFC UI while the CLI waits; CI auto-discarding via API; the run being discarded by a policy/gate externally.","solutions":["Re-run 'terraform apply' and confirm with 'yes' if you still want the changes.","If the discard came from the UI/API, coordinate with teammates to avoid concurrent discards.","Use -auto-approve (where appropriate) to avoid the interactive confirmation, or ensure the confirming user types 'yes'."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// errApplyDiscarded is an expected user-cancel; report it, do not retry.\nif err := b.confirm(stopCtx, op, opts, r, \"yes\"); err != nil {\n    if errors.Is(err, errApplyDiscarded) {\n        return errors.New(\"apply discarded: re-run 'terraform apply' and confirm 'yes' to proceed\")\n    }\n    return err\n}","preventionTips":["Train users to type exactly 'yes' (not 'y' or 'Y') at the confirmation prompt.","Coordinate with teammates to avoid discarding runs from the UI while the CLI waits.","Use -auto-approve in non-interactive CI where a discard-by-mistake is costly."],"tags":["backend","remote","tfe","apply","user-cancel"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}