hashicorp/terraform · info
errRunDiscarded
errRunDiscarded
Error message
discarded using the UI or API
What it means
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.
Source
Thrown at internal/cloud/errors.go:20
// SPDX-License-Identifier: BUSL-1.1
package cloud
import (
"errors"
"fmt"
"strings"
"github.com/hashicorp/terraform/internal/tfdiags"
"github.com/zclconf/go-cty/cty"
)
// String based errors
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")
errApplyNeedsUIConfirmation = errors.New("Cannot confirm apply due to -input=false. Please handle run confirmation in the UI.")
errPolicyOverrideNeedsUIConfirmation = errors.New("Cannot override soft failed policy checks when -input=false. Please open the run in the UI to override.")
)
// Diagnostic error messages
var (
invalidWorkspaceConfigMissingValues = tfdiags.AttributeValue(
tfdiags.Error,
"Invalid workspaces configuration",
fmt.Sprintf("Missing workspace mapping strategy. Either workspace \"tags\" or \"name\" is required.\n\n%s", workspaceConfigurationHelp),
cty.Path{cty.GetAttrStep{Name: "workspaces"}},
)
invalidWorkspaceConfigMisconfiguration = tfdiags.AttributeValue(
tfdiags.Error,
"Invalid workspaces configuration",
fmt.Sprintf("Only one of workspace \"tags\" or \"name\" is allowed.\n\n%s", workspaceConfigurationHelp),View on GitHub (pinned to d32a084675)
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.
Defensive patterns
Strategy: try-catch
Try / catch
// if errors.Is(err, cloud.ErrRunDiscarded) {
// log.Info("run was discarded externally during confirmation")
// // retry or alert as appropriate
// } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/82cfd7622868537e.
Report an issue: GitHub.