{"record":{"id":"699e68f536fc0f3b","repo":"hashicorp/terraform","slug":"the-pattern-cannot-be-used-more-than-once","errorCode":null,"errorMessage":"The pattern '*' cannot be used more than once.","messagePattern":"The pattern '\\*' cannot be used more than once\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/command/meta_backend_migrate.go","lineNumber":978,"sourceCode":"\t\t// returning a generic '*' that means use the same workspace name during\n\t\t// migration.\n\t\treturn \"*\", nil\n\t}\n\n\tpattern, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{\n\t\tId:          \"backend-migrate-multistate-to-tfc-pattern\",\n\t\tQuery:       fmt.Sprintf(\"[reset][bold][yellow]%s[reset]\", \"How would you like to rename your workspaces?\"),\n\t\tDescription: strings.TrimSpace(tfcInputBackendMigrateMultiToMultiPattern),\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error asking for state migration action: %s\", err)\n\t}\n\tif !strings.Contains(pattern, \"*\") {\n\t\treturn \"\", fmt.Errorf(\"The pattern must have an '*'\")\n\t}\n\n\tif count := strings.Count(pattern, \"*\"); count > 1 {\n\t\treturn \"\", fmt.Errorf(\"The pattern '*' cannot be used more than once.\")\n\t}\n\n\treturn pattern, nil\n}\n\nconst errMigrateLoadStates = `\nError inspecting states in the %q backend:\n    %s\n\nPrior to changing backends, Terraform inspects the source and destination\nstates to determine what kind of migration steps need to be taken, if any.\nTerraform failed to load the states. The data in both the source and the\ndestination remain unmodified. Please resolve the above error and try again.\n`\n\nconst errMigrateSingleLoadDefault = `\nError loading state:\n    %[2]s","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend_migrate.go#L960-L996","documentation":"Returned during multi-state-to-TFC workspace renaming when the user-supplied pattern contains more than one '*' character. Exactly one '*' is allowed because it is substituted with a single workspace name; multiple wildcards would be ambiguous.","triggerScenarios":"promptMultiStateMigrationPattern: after confirming the pattern contains '*', `strings.Count(pattern, \"*\")` returns a value greater than 1. Examples: 'a-*-b-*', '**', '*-*' all fail.","commonSituations":"User treats '*' as a glob and types '**'; user wants two substitution points (unsupported); accidental double asterisk from copy-paste or shell globbing.","solutions":["Re-enter a pattern with exactly one '*', e.g. 'prefix-*' or '*-prod'.","If you need more complex naming, perform migrations one workspace at a time or rename workspaces in the destination manually.","Avoid '**' and multiple '*' — only a single placeholder is supported."],"exampleFix":"// before\n// pattern entered: '*-*'  -> error (two '*')\n\n// after\n// pattern entered: 'migrated-*'","handlingStrategy":"validation","validationCode":"// Ensure at most one '*'\nif strings.Count(pattern, \"*\") > 1 {\n    return fmt.Errorf(\"pattern may contain at most one '*'\")\n}","typeGuard":"func isValidRenamePattern(p string) bool {\n    return strings.Contains(p, \"*\") && strings.Count(p, \"*\") == 1\n}","tryCatchPattern":null,"preventionTips":["Use exactly one '*' in the rename pattern.","Avoid '**' glob-style patterns; they are not supported.","For multiple distinct names, migrate workspaces individually instead.","Validate patterns before submitting them programmatically."],"tags":["terraform","backend-migration","input-validation","pattern","multi-state"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}