{"record":{"id":"48bf189f7b5b1d66","repo":"hashicorp/terraform","slug":"error-inspecting-states-in-the-q-s-s-prio","errorCode":null,"errorMessage":"Error inspecting states in the %q %s:\n    %s\n\nPrior to migration, Terraform inspects the source and destination\nstates to determine what kind of migration steps need to be taken, if any.\nTerraform failed to load the states. The data in both the source and the\ndestination remain unmodified. Please resolve the above error and try again.\n","messagePattern":"Error inspecting states in the %q (.+?):\n    (.+?)\n\nPrior to migration, Terraform inspects the source and destination\nstates to determine what kind of migration steps need to be taken, if any\\.\nTerraform failed to load the states\\. The data in both the source and the\ndestination remain unmodified\\. Please resolve the above error and try again\\.\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend_migrate.go","lineNumber":196,"sourceCode":"\t\t\t\t\"Do you want to migrate all workspaces to %s %q?\",\n\t\t\t\tdstWord, opts.DestinationType),\n\t\t\tDescription: fmt.Sprintf(\n\t\t\t\tstrings.TrimSpace(inputBackendMigrateMultiToMulti),\n\t\t\t\topts.SourceType, srcWord, opts.DestinationType, dstWord),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"Error asking for state migration action: %s\", err)\n\t\t}\n\t}\n\tif !migrate {\n\t\treturn fmt.Errorf(\"Migration aborted by user.\")\n\t}\n\n\t// Read all the states\n\tsourceWorkspaces, wDiags := opts.Source.Workspaces()\n\tif wDiags.HasErrors() {\n\t\treturn fmt.Errorf(strings.TrimSpace(\n\t\t\terrMigrateLoadStates), opts.SourceType, srcWord, wDiags.Err())\n\t}\n\tif wDiags.HasWarnings() {\n\t\tlog.Printf(\"[WARN] backendMigrateState_S_S: warning(s) returned when getting workspaces from source backend: %s\", wDiags.ErrWithWarnings())\n\t}\n\n\t// Sort the states so they're always copied alphabetically\n\tsort.Strings(sourceWorkspaces)\n\n\t// Go through each and migrate\n\tfor _, name := range sourceWorkspaces {\n\t\t// Copy the same names\n\t\topts.sourceWorkspace = name\n\t\topts.destinationWorkspace = name\n\n\t\t// Force it, we confirmed above\n\t\topts.force = true\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_backend_migrate.go#L178-L214","documentation":"Returned by the multi-state-to-multi-state path when listing workspaces from the source backend fails (`opts.Source.Workspaces()` returns diagnostics with errors). Terraform refuses to proceed because it cannot enumerate what to copy; both backends are left untouched.","triggerScenarios":"Fires right after the migration confirmation in `backendMigrateState_S_S` when `opts.Source.Workspaces()` yields a non-empty error diagnostics. Typical root causes: lost credentials, network failure to the remote backend, or a corrupted workspace index.","commonSituations":"Expired S3/GCS/Azure credentials during init, a remote backend endpoint that is unreachable, IAM permission changes that removed `ListObjects`/equivalent, or a partially-deleted workspace marker object.","solutions":["Re-authenticate to the backend (e.g. `aws sso login`, refresh the token, update credentials).","Verify network connectivity and the backend endpoint URL/region in the configuration.","Check IAM/object-store permissions for list access on the state prefix.","Retry `terraform init`; the error message embeds the underlying diagnostic for the specific failure."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Preflight: can the configured identity list source workspaces?\n# Example for S3:\naws s3 ls \"s3://${TF_BUCKET}/${TF_KEY_PREFIX}\" >/dev/null \\\n  && echo \"source listable\" || echo \"source list FAILED\"\nterraform init","typeGuard":null,"tryCatchPattern":"# Retry transient backend list failures a bounded number of times:\nfor i in 1 2 3; do\n  terraform init -input=false && break\n  if grep -q 'Error inspecting states' /tmp/init.log 2>/dev/null; then\n    echo \"retry $i after source list failure\"; sleep 5; continue\n  fi\n  exit 1\ndone","preventionTips":["Validate source backend credentials and list permissions before init.","Pin backend endpoints and confirm network reachability from the runner.","Use short-lived credentials refreshed immediately before init in CI."],"tags":["backend","migration","multi-state","workspaces","credentials","network"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}