hashicorp/terraform · error
Error asking for state migration action
Error message
Error asking for state migration action: %s
What it means
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.
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.
Example fix
# before terraform init -input=false # after terraform init -input=false -migrate-state=true
Defensive patterns
Strategy: validation
Validate before calling
# Decide migration intent BEFORE init so no prompt is needed.
# If you intend to migrate: pass the flag. If not, decline explicitly.
terraform init -input=false -migrate-state=${MIGRATE:-true} Try / catch
# Treat the prompt-failure as a config signal, not a transient error:
if ! terraform init -input=false >/tmp/init.log 2>&1; then
if grep -q 'Error asking for state migration action' /tmp/init.log; then
echo "Set -migrate-state=true|false explicitly in CI" >&2; exit 2
fi
cat /tmp/init.log; exit 1
fi Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error migrating the workspace %[1]q from the previous %[2]q…
- Migration aborted by user.
- Error copying state from the previous %[1]q %[2]s to the…
- Error creating temporary directory
- Error inspecting states in the
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/74db0353b833f34f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/command/meta_backend_migrate.go:185
srcWord := backendHumanName(opts.Source)
dstWord := backendHumanName(opts.Destination)
migrate := opts.force
if !migrate {
var err error
// Ask the user if they want to migrate their existing remote state
migrate, err = m.confirm(&terraform.InputOpts{
Id: "backend-migrate-multistate-to-multistate",
Query: fmt.Sprintf(
"Do you want to migrate all workspaces to %s %q?",
dstWord, opts.DestinationType),
Description: fmt.Sprintf(
strings.TrimSpace(inputBackendMigrateMultiToMulti),
opts.SourceType, srcWord, opts.DestinationType, dstWord),
})
if err != nil {
return fmt.Errorf(
"Error asking for state migration action: %s", err)
}
}
if !migrate {
return fmt.Errorf("Migration aborted by user.")
}
// Read all the states
sourceWorkspaces, wDiags := opts.Source.Workspaces()
if wDiags.HasErrors() {
return fmt.Errorf(strings.TrimSpace(
errMigrateLoadStates), opts.SourceType, srcWord, wDiags.Err())
}
if wDiags.HasWarnings() {
log.Printf("[WARN] backendMigrateState_S_S: warning(s) returned when getting workspaces from source backend: %s", wDiags.ErrWithWarnings())
}
// Sort the states so they're always copied alphabeticallyView on GitHub (pinned to d32a084675)