{"record":{"id":"0c7ef617bea1c96f","repo":"hashicorp/terraform","slug":"the-pattern-must-have-an","errorCode":null,"errorMessage":"The pattern must have an '*'","messagePattern":"The pattern must have an '\\*'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/command/meta_backend_migrate.go","lineNumber":974,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"Please select 1 or 2 as part of this option.\")\n\t}\n\tif renameWorkspaces == \"2\" {\n\t\t// this means they did not want to rename their workspaces, and we are\n\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`","sourceCodeStart":956,"sourceCodeEnd":992,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend_migrate.go#L956-L992","documentation":"Returned during multi-state-to-TFC workspace renaming when the user-supplied rename pattern does not contain a literal '*' character. The '*' is the placeholder substituted with each source workspace name, so the pattern must include exactly one.","triggerScenarios":"promptMultiStateMigrationPattern: user chose '1' and entered a pattern; `strings.Contains(pattern, \"*\")` is false. Examples: 'newname', 'prefix-', 'foo-#' all fail because there is no '*'.","commonSituations":"User misunderstands the pattern syntax and types a literal name without '*'; copy-paste drops the asterisk; user expects regex/glob and types '.' or '?'.","solutions":["Re-enter a pattern containing exactly one '*', e.g. 'prefix-*-suffix' or 'migrated-*'.","If you want the original name preserved verbatim, choose '2' (no rename) at the earlier prompt instead.","Do not use regex or '?' — only '*' is supported as the substitution token."],"exampleFix":"// before\n// pattern entered: 'newstate'  -> error (no '*')\n\n// after\n// pattern entered: 'newstate-*'","handlingStrategy":"validation","validationCode":"// Validate the rename pattern contains exactly one '*'\nfunc validPattern(p string) bool {\n    return strings.Contains(p, \"*\") && strings.Count(p, \"*\") == 1\n}\nif !validPattern(pattern) {\n    return fmt.Errorf(\"pattern must contain exactly one '*'\")\n}","typeGuard":"func isValidRenamePattern(p string) bool {\n    return strings.Contains(p, \"*\") && strings.Count(p, \"*\") == 1\n}","tryCatchPattern":null,"preventionTips":["Always include exactly one '*' in the rename pattern (e.g. 'prefix-*').","Do not use regex, '?', or '#' — only '*' is supported.","Choose '2' (no rename) at the earlier prompt if you want names unchanged.","Double-check pasted patterns did not drop the asterisk."],"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"}