{"record":{"id":"7ea29d109c4182fe","repo":"opentofu/opentofu","slug":"the-remote-backend-does-not-support-the-q-ope","errorCode":null,"errorMessage":"\n\nThe \"remote\" backend does not support the %q operation.","messagePattern":"\n\nThe \"remote\" backend does not support the %q operation\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote/backend.go","lineNumber":711,"sourceCode":"\t\treturn b.local.Operation(ctx, op)\n\t}\n\n\t// Set the remote workspace name.\n\top.Workspace = w.Name\n\n\t// Determine the function to call for our operation\n\tvar f func(context.Context, context.Context, context.Context, *backend.Operation, *tfe.Workspace) (*tfe.Run, error)\n\tswitch op.Type {\n\tcase backend.OperationTypePlan:\n\t\tf = b.opPlan\n\tcase backend.OperationTypeApply:\n\t\tf = b.opApply\n\tcase backend.OperationTypeRefresh:\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"\\n\\nThe \\\"refresh\\\" operation is not supported when using the \\\"remote\\\" backend. \" +\n\t\t\t\t\"Use \\\"tofu apply -refresh-only\\\" instead.\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"\\n\\nThe \\\"remote\\\" backend does not support the %q operation.\", op.Type)\n\t}\n\n\t// Lock\n\tb.opLock.Lock()\n\n\t// Build our running operation\n\t// the runningCtx is only used to block until the operation returns.\n\trunningCtx, done := context.WithCancel(context.Background())\n\trunningOp := &backend.RunningOperation{\n\t\tContext:   runningCtx,\n\t\tPlanEmpty: true,\n\t}\n\n\t// stopCtx wraps the context passed in, and is used to signal a graceful Stop.\n\tstopCtx, stop := context.WithCancel(ctx)\n\trunningOp.Stop = stop\n","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/backend/remote/backend.go#L693-L729","documentation":"The default branch of the operation dispatch switch in Remote.Operation (backend.go:711): op.Type is something other than Plan, Apply, or Refresh (refresh is special-cased with its own message). This is a programming-error path — the CLI itself never routes other operation types here, so embedders or custom frontends calling backend.Operation with an unexpected OperationType hit it.","triggerScenarios":"A Go program obtains a backend.Remote and calls Operation with an op.Type value outside the handled set (custom or newly added operation type constants), or a zero-value Operation struct whose Type was never set.","commonSituations":"Tooling built on the backend package that forwards user-supplied operation strings; refactors where a new OperationType constant is introduced without updating the remote backend switch; unit tests constructing bare Operation values.","solutions":["Set op.Type explicitly to backend.OperationTypePlan or OperationTypeApply before calling Operation","If you maintain a caller of backend.Operation, validate/whitelist the operation type before dispatch","For refresh-style needs use OperationTypePlan/Apply with refresh-only semantics instead","Return a clear error to your own users rather than forwarding unknown types into the backend"],"exampleFix":"// before\nop := &backend.Operation{Type: backend.OperationType(0)} // zero/unknown\n_, err := b.Operation(ctx, op) // -> \"does not support the \\\"%!z(...)\\\" operation.\"\n\n// after\nop := &backend.Operation{Type: backend.OperationTypePlan}\n_, err := b.Operation(ctx, op)","handlingStrategy":"validation","validationCode":"// whitelist operation types before calling backend.Operation\nfunc validOpType(t backend.OperationType) bool {\n  switch t {\n  case backend.OperationTypePlan, backend.OperationTypeApply, backend.OperationTypeRefresh:\n    return true\n  }\n  return false\n}\nif !validOpType(op.Type) {\n  return fmt.Errorf(\"unsupported operation type: %d\", op.Type)\n}","typeGuard":"func isUnsupportedOpErr(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"does not support the\") && strings.Contains(err.Error(), \"operation\")\n}","tryCatchPattern":"// treat as a programmer error: fail fast with the caller's own context\nif _, err := b.Operation(ctx, op); err != nil {\n  if isUnsupportedOpErr(err) {\n    return fmt.Errorf(\"wrapper bug: op.Type=%d rejected by remote backend: %w\", op.Type, err)\n  }\n  return err\n}","preventionTips":["Always set Operation.Type explicitly; never rely on zero values","Unit-test wrappers with every OperationType you forward","When adding new OperationType constants, grep backend implementations for switch coverage"],"tags":["remote-backend","go","api-misuse","operation"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}