hashicorp/terraform · error

does not support the operation.

Error message


%s does not support the %q operation.

What it means

Default branch of the Operation type switch—every supported op type (plan/apply/refresh/etc.) is handled above; reaching the default means op.Type is something the cloud backend has no implementation for. Refresh is special-cased earlier and rewritten to apply -refresh-state, so it does not reach here.

Solutions

  1. Confirm the operation type is supported by the Cloud backend and use a local backend for ops it does not handle.
  2. If you maintain a wrapper, map the unsupported op to one the backend implements (plan/apply/refresh) before dispatch.
  3. File an issue / upgrade—the operation may be supported in a newer backend version.
Defensive patterns

Strategy: validation

Validate before calling

// before dispatching an op, confirm the backend supports it
var cloudSupportedOps = map[backendrun.OperationType]bool{
    backendrun.OperationTypePlan: true,
    backendrun.OperationTypeApply: true,
    // refresh is rewritten internally; others are not
}
func dispatch(b backendrun.OperationsBackend, op *backendrun.Operation) error {
    if !cloudSupportedOps[op.Type] {
        return fmt.Errorf("op %v unsupported by cloud backend", op.Type)
    }
    _, err := b.Operation(ctx, op)
    return err
}

Type guard

func isSupportedCloudOp(t backendrun.OperationType) bool {
    switch t {
    case backendrun.OperationTypePlan, backendrun.OperationTypeApply, backendrun.OperationTypeRefresh:
        return true
    }
    return false
}

Prevention

When it happens

Trigger: Calling code dispatches a backendrun.Operation with an OperationType not covered by the switch (e.g. a hypothetical console/import/unknown custom op). Practically reachable only by internal callers or future op types not yet wired into the cloud backend.

Common situations: End users essentially never see this; it appears when a tool built on the backend layer invokes an operation type the Cloud backend does not implement (e.g. an experimental op).

Related errors


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

Appendix: source

Thrown at internal/cloud/backend.go:933

			f = b.opQuery
		} else {
			f = b.opPlan
		}
	case backendrun.OperationTypeApply:
		f = b.opApply
	case backendrun.OperationTypeRefresh:
		// The `terraform refresh` command has been deprecated in favor of `terraform apply -refresh-state`.
		// Rather than respond with an error telling the user to run the other command we can just run
		// that command instead. We will tell the user what we are doing, and then do it.
		if b.CLI != nil {
			b.CLI.Output(b.Colorize().Color(strings.TrimSpace(refreshToApplyRefresh) + "\n"))
		}
		op.PlanMode = plans.RefreshOnlyMode
		op.PlanRefresh = true
		op.AutoApprove = true
		f = b.opApply
	default:
		return nil, fmt.Errorf(
			"\n\n%s does not support the %q operation.", b.appName, op.Type)
	}

	// Lock
	b.opLock.Lock()

	// Build our running operation
	// the runninCtx is only used to block until the operation returns.
	runningCtx, done := context.WithCancel(context.Background())
	runningOp := &backendrun.RunningOperation{
		Context:   runningCtx,
		PlanEmpty: true,
	}

	// stopCtx wraps the context passed in, and is used to signal a graceful Stop.
	stopCtx, stop := context.WithCancel(ctx)
	runningOp.Stop = stop

View on GitHub (pinned to d32a084675)