{"record":{"id":"f46e04278bd29856","repo":"hashicorp/terraform","slug":"error-migrating-the-workspace-1-q-from-the-previ-f46e04","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.","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\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend_migrate.go","lineNumber":805,"sourceCode":"\n\t// Go through each and migrate\n\tfor _, name := range sourceWorkspaces {\n\n\t\t// Copy the same names\n\t\topts.sourceWorkspace = name\n\t\tif newName, ok := defaultNewName[name]; ok {\n\t\t\t// this has to be done before setting destinationWorkspace\n\t\t\tname = newName\n\t\t}\n\t\topts.destinationWorkspace = strings.Replace(pattern, \"*\", name, -1)\n\n\t\t// Force it, we confirmed above\n\t\topts.force = true\n\n\t\t// Perform the migration\n\t\tlog.Printf(\"[INFO] backendMigrateTFC: multi-to-multi migration, source workspace %q to destination workspace %q\", opts.sourceWorkspace, opts.destinationWorkspace)\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\n\t\tif currentWorkspace == opts.sourceWorkspace {\n\t\t\tnewCurrentWorkspace = opts.destinationWorkspace\n\t\t}\n\t}\n\n\t// After migrating multiple workspaces, we need to reselect the current workspace as it may\n\t// have been renamed. Query the backend first to be sure it now exists.\n\tworkspaces, diags := opts.Destination.Workspaces()\n\tif diags.HasErrors() {\n\t\treturn diags.Err()\n\t}\n\tif diags.HasWarnings() {\n\t\tlog.Printf(\"[WARN] backendMigrateState_S_TFC: warning(s) returned when getting workspaces from destination backend: %s\", diags.ErrWithWarnings())","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_backend_migrate.go#L787-L823","documentation":"During multi-workspace migration to HCP Terraform, each source workspace is migrated individually via backendMigrateState_s_s. If any single workspace's migration fails, this error names the failing workspace and explains the alphabetical-order invariant: workspaces before it in alphabetical order have already been copied, later ones are untouched, and the source is never modified. Re-running init re-attempts all workspaces.","triggerScenarios":"A per-workspace state copy operation fails mid-migration. The error could come from HCP Terraform API rate limiting, workspace creation failure, destination workspace naming conflict, or a transient network error during a specific workspace's state push.","commonSituations":"HCP Terraform API rate limits hit during bulk workspace migration, workspace name already exists in the destination organization, insufficient permissions on the destination, network blip during a large workspace state upload, or TFC org-level workspace count limits reached.","solutions":["Read the embedded %[6]s error to identify the specific cause for the failing workspace","Resolve the underlying issue (e.g., delete a conflicting workspace, request higher API limits, fix permissions)","Re-run `terraform init` to retry — it will re-copy all workspaces with permission prompts","If a single workspace is problematic, migrate it separately after the bulk migration completes","Check HCP Terraform organization settings for workspace limits or naming policies"],"exampleFix":"# before: workspace name conflict causes multi-workspace migration failure\nterraform init\n# after: resolve conflict, re-run init\nterraform workspace delete -force conflicting-name  # in TFC UI/API\nterraform init","handlingStrategy":"retry","validationCode":"// Before multi-workspace migration, check destination workspace limits and naming conflicts\nfunc preflightMultiMigration(dest backend.Backend, sourceWorkspaces []string) error {\n    existing, diags := dest.Workspaces()\n    if diags.HasErrors() {\n        return diags.Err()\n    }\n    existingSet := make(map[string]bool)\n    for _, w := range existing {\n        existingSet[w] = true\n    }\n    for _, w := range sourceWorkspaces {\n        if existingSet[w] {\n            return fmt.Errorf(\"workspace %q already exists in destination\", w)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Multi-workspace migration is designed to be retried — re-running init\n// re-attempts all workspaces with permission prompts. Wrap with retry logic\n// for transient failures (rate limits, network blips):\n// for i := 0; i < 3; i++ {\n//     err := terraformInit()\n//     if err == nil { break }\n//     if isTransient(err) { time.Sleep(backoff(i)); continue }\n//     return err\n// }","preventionTips":["Pre-check for workspace name conflicts in the destination before migration","Monitor HCP Terraform API rate limits during bulk workspace migration","Ensure the destination organization has sufficient workspace quota","Migrate workspaces in smaller batches if rate limits are a concern"],"tags":["backend","migration","multi-workspace","partial-failure","hcp-terraform"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}