{"record":{"id":"5df6dc458dddb923","repo":"hashicorp/terraform","slug":"error-starting-operation-s","errorCode":null,"errorMessage":"error starting operation: %s","messagePattern":"error starting operation: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta.go","lineNumber":503,"sourceCode":"// until that operation completes or is interrupted, and then returns\n// the RunningOperation object representing the completed or\n// aborted operation that is, despite the name, no longer running.\n//\n// An error is returned if the operation either fails to start or is cancelled.\n// If the operation runs to completion then no error is returned even if the\n// operation itself is unsuccessful. Use the \"Result\" field of the\n// returned operation object to recognize operation-level failure.\nfunc (m *Meta) RunOperation(b backendrun.OperationsBackend, opReq *backendrun.Operation) (*backendrun.RunningOperation, error) {\n\tif opReq.View == nil {\n\t\tpanic(\"RunOperation called with nil View\")\n\t}\n\tif opReq.ConfigDir != \"\" {\n\t\topReq.ConfigDir = m.normalizePath(opReq.ConfigDir)\n\t}\n\n\top, err := b.Operation(m.CommandContext(), opReq)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error starting operation: %s\", err)\n\t}\n\n\t// Wait for the operation to complete or an interrupt to occur\n\tselect {\n\tcase <-m.ShutdownCh:\n\t\t// gracefully stop the operation\n\t\top.Stop()\n\n\t\t// Notify the user\n\t\topReq.View.Interrupted()\n\n\t\t// Still get the result, since there is still one\n\t\tselect {\n\t\tcase <-m.ShutdownCh:\n\t\t\topReq.View.FatalInterrupt()\n\n\t\t\t// cancel the operation completely\n\t\t\top.Cancel()","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta.go#L485-L521","documentation":"Returned by Meta.RunOperation when the backend's Operation() factory call fails to even start the requested operation (plan/apply/refresh). This is distinct from an operation that runs but produces errors — here the operations backend could not construct or queue the operation at all. The underlying cause is surfaced via %s so it is always a wrapped backend-specific error.","triggerScenarios":"Calling RunOperation with a backend whose Operation() method returns a non-nil error. This happens when the backend implementation rejects the Operation request struct (nil fields, unsupported operation type, resource limits, lost connection to remote state) before any work begins.","commonSituations":"A remote/cloud backend that lost its API token or network connection; a local backend with an unreadable config directory; a custom backend plugin that crashed or returned an error from its gRPC Operation RPC; running apply/plan in CI with a misconfigured backend.","solutions":["Inspect the wrapped %s error — it contains the backend-specific root cause (auth, network, schema).","Verify backend configuration is valid with `terraform init` and that credentials/secrets are present in the environment.","If using a custom or external backend plugin, check the plugin process is running and compatible with this Terraform version.","Re-run the command with TF_LOG=TRACE to capture the backend Operation() call details."],"exampleFix":"// before: backend creds missing, operation fails to start\nterraform apply\n// after: provide credentials and re-init\nexport TF_TOKEN_remote_host=xxxx\nterraform init\nterraform apply","handlingStrategy":"try-catch","validationCode":"// Validate backend is reachable before RunOperation\nif b == nil {\n    return fmt.Errorf(\"backend is nil; run terraform init first\")\n}\nif _, d := b.Workspaces(); d.HasErrors() {\n    return fmt.Errorf(\"backend not ready: %s\", d.Err())\n}","typeGuard":"// Confirm b supports operations before calling\nif _, ok := b.(backendrun.OperationsBackend); !ok {\n    // backend will be wrapped in local; proceed with caution\n    log.Printf(\"[WARN] backend %T is not an OperationsBackend\", b)\n}","tryCatchPattern":"op, err := m.RunOperation(b, opReq)\nif err != nil {\n    // surface to user; do NOT retry blindly — inspect wrapped cause\n    return fmt.Errorf(\"cannot proceed with operation: %w\", err)\n}","preventionTips":["Run `terraform init` to validate backend config before plan/apply.","Ensure backend credentials are present in the environment before any operation.","Use TF_LOG=TRACE in CI to capture backend Operation() failure details for diagnosis."],"tags":["backend","operation","plan","apply","init"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}