{"record":{"id":"76b679ada0257e80","repo":"hashicorp/terraform","slug":"error-migrating-the-workspace-1-q-from-the-previ","errorCode":null,"errorMessage":"Error migrating the workspace %[1]q from the previous %[2]q %[3]s\nto the newly configured %[4]q %[5]s:\n    %[6]s\n\nTerraform copies workspaces in alphabetical order. Any workspaces\nalphabetically earlier than this one have been copied. Any workspaces\nlater than this haven't been modified in the destination. No workspaces\nin the source state have been modified.\n\nPlease resolve the error above and run the initialization command again.\nThis will attempt to copy (with permission) all workspaces again.\n","messagePattern":"Error migrating the workspace %\\[1\\]q from the previous %\\[2\\]q %\\[3\\]s\nto the newly configured %\\[4\\]q %\\[5\\]s:\n    %\\[6\\]s\n\nTerraform copies workspaces in alphabetical order\\. Any workspaces\nalphabetically earlier than this one have been copied\\. Any workspaces\nlater than this haven't been modified in the destination\\. No workspaces\nin the source state have been modified\\.\n\nPlease resolve the error above and run the initialization command again\\.\nThis will attempt to copy \\(with permission\\) all workspaces again\\.\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend_migrate.go","lineNumber":217,"sourceCode":"\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\n\t\t// Perform the migration\n\t\tif err := m.backendMigrateState_s_s(opts); err != nil {\n\t\t\treturn fmt.Errorf(strings.TrimSpace(\n\t\t\t\terrMigrateMulti), name,\n\t\t\t\topts.SourceType, srcWord,\n\t\t\t\topts.DestinationType, dstWord, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Multi-state to single state.\nfunc (m *Meta) backendMigrateState_S_s(opts *backendMigrateOpts) error {\n\tlog.Printf(\"[INFO] backendMigrateState: destination backend type %q does not support named workspaces\", opts.DestinationType)\n\n\tcurrentWorkspace, err := m.Workspace()\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_backend_migrate.go#L199-L235","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Check destination write quota/permissions before migrating:\n# S3 example:\naws s3 mb \"s3://${DST_BUCKET}\" 2>/dev/null || true\naws s3 ls \"s3://${DST_BUCKET}/\" >/dev/null && echo ok\nterraform init -input=false -migrate-state=true","typeGuard":null,"tryCatchPattern":"# Re-run init on partial per-workspace failure; reconciliation is idempotent:\nfor i in 1 2 3; do\n  terraform init -input=false -migrate-state=true && break\n  grep -q 'Error migrating the workspace' /tmp/init.log || { cat /tmp/init.log; exit 1; }\n  echo \"partial migration failure, retry $i\"; sleep 10\ndone","preventionTips":["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."],"tags":["backend","migration","multi-state","partial-failure","retry","init"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}