hashicorp/terraform · error
Error migrating the workspace %[1]q from the previous %[2]q
Error message
Error migrating the workspace %[1]q from the previous %[2]q %[3]s
to the newly configured %[4]q %[5]s:
%[6]s
Terraform copies workspaces in alphabetical order. Any workspaces
alphabetically earlier than this one have been copied. Any workspaces
later than this haven't been modified in the destination. No workspaces
in the source state have been modified.
Please resolve the error above and run the initialization command again.
This will attempt to copy (with permission) all workspaces again.
What it means
Returned when copying an individual workspace inside a multi-state-to-multi-state migration fails. Because workspaces are copied in alphabetical order, earlier workspaces are already copied, later ones are untouched, and the source is never modified. The user is told to fix the error and re-run init, which re-attempts the full copy with confirmation.
Source
Thrown at internal/command/meta_backend_migrate.go:217
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 alphabetically
sort.Strings(sourceWorkspaces)
// Go through each and migrate
for _, name := range sourceWorkspaces {
// Copy the same names
opts.sourceWorkspace = name
opts.destinationWorkspace = name
// Force it, we confirmed above
opts.force = true
// Perform the migration
if err := m.backendMigrateState_s_s(opts); err != nil {
return fmt.Errorf(strings.TrimSpace(
errMigrateMulti), name,
opts.SourceType, srcWord,
opts.DestinationType, dstWord, err)
}
}
return nil
}
// Multi-state to single state.
func (m *Meta) backendMigrateState_S_s(opts *backendMigrateOpts) error {
log.Printf("[INFO] backendMigrateState: destination backend type %q does not support named workspaces", opts.DestinationType)
currentWorkspace, err := m.Workspace()
if err != nil {
return err
}
View on GitHub (pinned to d32a084675)
Solutions
- Re-run `terraform init -migrate-state=true`; already-copied workspaces will reconcile and the failed one is retried.
- Inspect the embedded `%[6]s` underlying error to determine whether it is auth, quota, or corruption.
- Increase destination backend quotas/permissions, then retry.
- If a specific workspace is corrupt, exclude or repair it in the source before re-running.
Defensive patterns
Strategy: retry
Validate before calling
# Check destination write quota/permissions before migrating:
# S3 example:
aws s3 mb "s3://${DST_BUCKET}" 2>/dev/null || true
aws s3 ls "s3://${DST_BUCKET}/" >/dev/null && echo ok
terraform init -input=false -migrate-state=true Try / catch
# Re-run init on partial per-workspace failure; reconciliation is idempotent:
for i in 1 2 3; do
terraform init -input=false -migrate-state=true && break
grep -q 'Error migrating the workspace' /tmp/init.log || { cat /tmp/init.log; exit 1; }
echo "partial migration failure, retry $i"; sleep 10
done Prevention
- Size destination quota for the total state across all workspaces.
- Run migrations with exclusive access to avoid concurrent writes.
- Read the embedded underlying error before retrying blindly.
When it happens
Trigger: Fires inside the `for _, name := range sourceWorkspaces` loop in `backendMigrateState_S_S` when `m.backendMigrateState_s_s(opts)` returns an error for a single workspace (state load, lock, copy, or persist failure).
Common situations: Transient destination write failure mid-migration (rate limiting, quota), a workspace whose state is too large for the destination backend, or destination credential expiration discovered only at write time.
Related errors
- Error asking for state migration action: %s
- Migration aborted by user.
- Error locking state: %s
- Error inspecting states in the %q %s: %s Prior to migra
- Error loading state: %[3]s Terraform failed to load the
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/76b679ada0257e80.
Report an issue: GitHub.