{"record":{"id":"2f10a00adea28dd0","repo":"hashicorp/terraform","slug":"please-select-1-or-2-as-part-of-this-option","errorCode":null,"errorMessage":"Please select 1 or 2 as part of this option.","messagePattern":"Please select 1 or 2 as part of this option\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/command/meta_backend_migrate.go","lineNumber":956,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"Error asking for new state name: %s\", err)\n\t}\n\n\treturn name, nil\n}\n\nfunc (m *Meta) promptMultiStateMigrationPattern(sourceType string, appName string) (string, error) {\n\t// This is not the first prompt a user would be presented with in the migration to TFC, so no\n\t// guard on m.input is needed here.\n\trenameWorkspaces, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{\n\t\tId:          \"backend-migrate-multistate-to-tfc\",\n\t\tQuery:       fmt.Sprintf(\"[reset][bold][yellow]%s[reset]\", \"Would you like to rename your workspaces?\"),\n\t\tDescription: fmt.Sprintf(strings.TrimSpace(tfcInputBackendMigrateMultiToMulti), sourceType, appName),\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error asking for state migration action: %s\", err)\n\t}\n\tif renameWorkspaces != \"2\" && renameWorkspaces != \"1\" {\n\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 '*'\")","sourceCodeStart":938,"sourceCodeEnd":974,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend_migrate.go#L938-L974","documentation":"Returned when the user, at the 'rename workspaces?' prompt during multi-state-to-TFC migration, typed something other than exactly '1' or '2'. The value must be one of those two literal choices; '1' means rename with a pattern, '2' means keep names as-is.","triggerScenarios":"promptMultiStateMigrationPattern receives a renameWorkspaces value that is neither \"1\" nor \"2\" — e.g. '3', 'yes', '1 ', an empty string, or '12'. The guard `if renameWorkspaces != \"2\" && renameWorkspaces != \"1\"` fires.","commonSituations":"User misreads the prompt and types 'yes'/'no'; stray whitespace/newline; pasted multi-character answer; non-English locale confusion about the numeric choice.","solutions":["Re-run init and type exactly '1' (rename with a pattern) or '2' (do not rename) at the prompt.","If you do not want renaming, choose '2'.","If automating, supply the exact token via a controlled pipe.","Avoid -force/extra flags that do not apply to this prompt; the choice is strictly 1 or 2."],"exampleFix":"// before\n// at prompt: type 'yes'  -> error\n\n// after\n// at prompt: type '1'  (rename) or '2' (keep names)","handlingStrategy":"validation","validationCode":"// When automating the rename prompt, supply exactly '1' or '2'.\ninput := strings.TrimSpace(answer)\nif input != \"1\" && input != \"2\" {\n    return fmt.Errorf(\"must answer 1 or 2\")\n}\n_ = input","typeGuard":"func isValidRenameChoice(s string) bool {\n    return s == \"1\" || s == \"2\"\n}","tryCatchPattern":null,"preventionTips":["Answer the prompt with exactly '1' (rename) or '2' (keep names).","Trim whitespace if piping answers programmatically.","Do not type 'yes'/'no' — only the two numeric tokens are accepted.","Read the prompt text to understand what 1 and 2 mean."],"tags":["terraform","backend-migration","input-validation","multi-state","hcp-terraform"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}