{"record":{"id":"74db0353b833f34f","repo":"hashicorp/terraform","slug":"error-asking-for-state-migration-action-s","errorCode":null,"errorMessage":"Error asking for state migration action: %s","messagePattern":"Error asking for state migration action: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend_migrate.go","lineNumber":181,"sourceCode":"// Multi-state to multi-state.\nfunc (m *Meta) backendMigrateState_S_S(opts *backendMigrateOpts) error {\n\tlog.Print(\"[INFO] backendMigrateState: migrating all named workspaces\")\n\n\tmigrate := opts.force\n\tif !migrate {\n\t\tvar err error\n\t\t// Ask the user if they want to migrate their existing remote state\n\t\tmigrate, err = m.confirm(&terraform.InputOpts{\n\t\t\tId: \"backend-migrate-multistate-to-multistate\",\n\t\t\tQuery: fmt.Sprintf(\n\t\t\t\t\"Do you want to migrate all workspaces to %q?\",\n\t\t\t\topts.DestinationType),\n\t\t\tDescription: fmt.Sprintf(\n\t\t\t\tstrings.TrimSpace(inputBackendMigrateMultiToMulti),\n\t\t\t\topts.SourceType, opts.DestinationType),\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, 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","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend_migrate.go#L163-L199","documentation":"In Meta.backendMigrateState_S_S (meta_backend_migrate.go:181), the multi-state-to-multi-state migration path asks the user to confirm migrating all workspaces via m.confirm(). If the confirm prompt itself errors (no TTY, EOF, closed stdin, UI failure), this wraps it. It is about the INPUT mechanism failing, not the migration logic.","triggerScenarios":"A backend migration where both source and destination support named workspaces (e.g. remote->remote, cloud->cloud) running in a non-interactive context where the confirmation prompt cannot be answered; stdin closed or not a terminal.","commonSituations":"CI/containers with no TTY performing a multi-state migration; scripts that close stdin or auto-feed invalid input; a custom UI returning an error.","solutions":["Run the migration with `-input=false` plus `-migrate-state` (and/or `-force-copy` if appropriate) so no prompt is required.","Run once interactively to answer the prompt, if a TTY is available.","Ensure stdin is open / a PTY is attached when you expect to answer interactively.","Inspect the wrapped `%s` for the specific input error."],"exampleFix":"// before: terraform init   (multi-state migration; CI; fails: Error asking for state migration action)\n// after: terraform init -migrate-state -input=false","handlingStrategy":"validation","validationCode":"// In non-interactive contexts, avoid the migration confirmation prompt entirely.\nfunc migrationNeedsFlags(inputEnabled bool, migrateWanted bool) []string {\n    if !inputEnabled && migrateWanted { return []string{\"-migrate-state\", \"-input=false\"} }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `-migrate-state -input=false` for automated multi-state migrations.","Run migrations interactively when a TTY is available.","Don't close/EOF stdin during interactive migration prompts.","Pre-validate both source and destination backends before migrating."],"tags":["state","migration","input","interactive","ci"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}