{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend_migrate.go","lineNumber":185,"sourceCode":"\n\tsrcWord := backendHumanName(opts.Source)\n\tdstWord := backendHumanName(opts.Destination)\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 %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","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_backend_migrate.go#L167-L203","documentation":"Returned by the multi-state-to-multi-state migration path when the confirmation UI prompt itself fails (not when the user declines). The underlying `m.confirm(...)` returned a non-nil error, typically from a broken or unavailable input channel during `terraform init` backend migration.","triggerScenarios":"Fires in `backendMigrateState_S_S` when `opts.force` is false and `m.confirm(&terraform.InputOpts{Id: \"backend-migrate-multistate-to-multistate\"})` returns an error. Common when input is disabled (`-input=false`) but no force/`-migrate-state` flag was supplied, or the UIInput adapter is nil.","commonSituations":"Running `terraform init -input=false` after changing the backend `workspaces` config between two multi-workspace backends without passing `-migrate-state=true`, or in CI where no TTY is attached.","solutions":["Re-run with `-input=false -migrate-state=true` (or `-migrate-state=false` to discard source state).","Run in an interactive shell so the prompt can be answered.","Ensure the backend change is intentional; if not, revert the backend block so no migration prompt is needed."],"exampleFix":"# before\nterraform init -input=false\n# after\nterraform init -input=false -migrate-state=true","handlingStrategy":"validation","validationCode":"# Decide migration intent BEFORE init so no prompt is needed.\n# If you intend to migrate: pass the flag. If not, decline explicitly.\nterraform init -input=false -migrate-state=${MIGRATE:-true}","typeGuard":null,"tryCatchPattern":"# Treat the prompt-failure as a config signal, not a transient error:\nif ! terraform init -input=false >/tmp/init.log 2>&1; then\n  if grep -q 'Error asking for state migration action' /tmp/init.log; then\n    echo \"Set -migrate-state=true|false explicitly in CI\" >&2; exit 2\n  fi\n  cat /tmp/init.log; exit 1\nfi","preventionTips":["Always pair -input=false with an explicit -migrate-state value in CI.","Keep backend config in version control so migrations are intentional and reviewed.","Run init interactively once after a backend change to confirm the prompt behaves as expected."],"tags":["backend","migration","multi-state","interactive-prompt","init"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}