hashicorp/terraform · info

errApplyDiscarded

errApplyDiscarded

Error message

Apply discarded.

What it means

Returned by the Terraform Cloud backend when an apply run is discarded before it executes. The discard can originate from the local confirmation prompt (user typed something other than 'yes') or from an external action via the TFC/TFE UI or API. It is a sentinel error defined in internal/cloud/errors.go and set in backend_common.go within the confirm() goroutine when run status becomes RunDiscarded or when the user declines confirmation.

Source

Thrown at internal/cloud/errors.go:17

// Copyright IBM Corp. 2014, 2026
// 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(

View on GitHub (pinned to d32a084675)

Solutions

  1. Re-run 'terraform apply' if the discard was unintentional.
  2. If discarding was intentional, no action is needed — this is expected control flow, not a bug.
  3. Coordinate with team members to avoid concurrent UI/API and CLI operations on the same workspace.
  4. Use -auto-approve to bypass interactive confirmation if you want unattended applies.

Example fix

// before: interactive apply that gets discarded
terraform apply
// user types 'no' -> Apply discarded.

// after: auto-approve to avoid discard-by-prompt
terraform apply -auto-approve
Defensive patterns

Strategy: try-catch

Try / catch

// In Go code wrapping terraform CLI execution:
// if errors.Is(err, cloud.ErrApplyDiscarded) {
//     log.Info("apply was discarded, not a failure")
//     return nil // treat as non-error in automation
// }

Prevention

When it happens

Trigger: Running 'terraform apply' against a cloud-backed workspace, responding with anything other than 'yes' at the approval prompt, or having the run discarded externally (UI/API) while the CLI is waiting for interactive confirmation. backend_common.go:490-491 maps errRunDiscarded to errApplyDiscarded for non-destroy plan modes.

Common situations: A CI pipeline or operator aborts the apply by typing 'no'; another team member cancels the run in the Terraform Cloud UI while the CLI is still polling; an automation tool sends a Discard API call concurrently with a local apply.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/414dd52ed655963f. Report an issue: GitHub.