hashicorp/terraform · info
discarded using the UI or API
Error message
discarded using the UI or API
What it means
Sentinel error raised inside the remote backend confirm() polling loop when the polled run transitions to tfe.RunDiscarded. It signals that the run was discarded via the UI or API while the CLI was waiting for local confirmation, and it is then rewritten to errApplyDiscarded or errDestroyDiscarded to abort the operation cleanly.
Source
Thrown at internal/backend/remote/backend_common.go:29
"io"
"math"
"strconv"
"strings"
"time"
tfe "github.com/hashicorp/go-tfe"
"github.com/hashicorp/terraform/internal/backend/backendrun"
"github.com/hashicorp/terraform/internal/logging"
"github.com/hashicorp/terraform/internal/plans"
"github.com/hashicorp/terraform/internal/terraform"
)
var (
errApplyDiscarded = errors.New("Apply discarded.")
errDestroyDiscarded = errors.New("Destroy discarded.")
errRunApproved = errors.New("approved using the UI or API")
errRunDiscarded = errors.New("discarded using the UI or API")
errRunOverridden = errors.New("overridden using the UI or API")
)
var (
backoffMin = 1000.0
backoffMax = 3000.0
runPollInterval = 3 * time.Second
)
// backoff will perform exponential backoff based on the iteration and
// limited by the provided min and max (in milliseconds) durations.
func backoff(min, max float64, iter int) time.Duration {
backoff := math.Pow(2, float64(iter)/5) * min
if backoff > max {
backoff = max
}
return time.Duration(backoff) * time.MillisecondView on GitHub (pinned to c9def3e214)
Solutions
- Re-run the plan/apply once the conflicting discard is resolved; the discarded run cannot be resumed.
- Coordinate run ownership (assign the run, comment in the UI) so only one actor confirms or discards.
- If discards are automated, exclude workspaces that humans operate on interactively.
Defensive patterns
Strategy: try-catch
Try / catch
if err := b.confirm(ctx, op, opts, run, "yes"); err != nil {
if errors.Is(err, errRunDiscarded) || errors.Is(err, errApplyDiscarded) || errors.Is(err, errDestroyDiscarded) {
// run was discarded via UI/API — surface to user, no retry of this run
return run, err
}
return run, err
} Prevention
- Coordinate who may discard runs in shared workspaces.
- Surface a clear user message that the run was discarded externally and must be re-planned.
- Do not auto-retry on discard — start a fresh plan instead.
When it happens
Trigger: During 'terraform apply' (or destroy) confirmation on a 'remote' backend, the run is discarded through the TFE/HCP UI 'Discard run' button or POST /runs/{id}/actions/discard before the operator types the keyword.
Common situations: A teammate cancels a stale run; CI discards a run that a developer is also reviewing at the prompt; a policy or automation discards runs in a queued state.
Related errors
- approved using the UI or API
- overridden using the UI or API
- operation timed out
- your version of Terraform Enterprise does not support key-va
- operation timed out
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/4ae4bbdb31ff0a50.
Report an issue: GitHub.