{"record":{"id":"712c0fd0ef78d768","repo":"hashicorp/terraform","slug":"couldn-t-create-initial-workspace-no-name-provide","errorCode":null,"errorMessage":"Couldn't create initial workspace: no name provided","messagePattern":"Couldn't create initial workspace: no name provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend.go","lineNumber":266,"sourceCode":"\tif diags.HasWarnings() {\n\t\tlog.Printf(\"[WARN] selectWorkspace: warning(s) returned when getting workspaces: %s\", diags.ErrWithWarnings())\n\t}\n\tif len(workspaces) == 0 {\n\t\tif c, ok := b.(*cloud.Cloud); ok && m.input {\n\t\t\t// len is always 1 if using Name; 0 means we're using Tags and there\n\t\t\t// aren't any matching workspaces. Which might be normal and fine, so\n\t\t\t// let's just ask:\n\t\t\tname, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{\n\t\t\t\tId:          \"create-workspace\",\n\t\t\t\tQuery:       \"\\n[reset][bold][yellow]No workspaces found.[reset]\",\n\t\t\t\tDescription: fmt.Sprintf(inputCloudInitCreateWorkspace, c.WorkspaceMapping.DescribeTags()),\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Couldn't create initial workspace: %w\", err)\n\t\t\t}\n\t\t\tname = strings.TrimSpace(name)\n\t\t\tif name == \"\" {\n\t\t\t\treturn fmt.Errorf(\"Couldn't create initial workspace: no name provided\")\n\t\t\t}\n\t\t\tlog.Printf(\"[TRACE] Meta.selectWorkspace: selecting the new HCP Terraform workspace requested by the user (%s)\", name)\n\t\t\treturn m.SetWorkspace(name)\n\t\t} else {\n\t\t\treturn &errBackendNoExistingWorkspaces{}\n\t\t}\n\t}\n\n\t// Get the currently selected workspace.\n\tworkspace, err := m.Workspace()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Check if any of the existing workspaces matches the selected\n\t// workspace and create a numbered list of existing workspaces.\n\tvar list strings.Builder\n\tfor i, w := range workspaces {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_backend.go#L248-L284","documentation":"Returned from `Meta.selectWorkspace` when the cloud create-workspace prompt succeeded (no `UIInput` error) but the user typed only whitespace or pressed Enter without a name. `strings.TrimSpace(name)` yields an empty string, so the workspace cannot be created or selected.","triggerScenarios":"User pressed Enter at the 'No workspaces found' prompt without typing a name, or typed only spaces/tabs. Distinct from error 651, which fires when the prompt itself errors.","commonSituations":"User unsure what to type and hits Enter to 'skip'; accidental Enter; a piped empty line (`echo '' | terraform init`) feeding the prompt.","solutions":["Re-run and type a valid workspace name at the prompt (letters, digits, dashes, underscores).","Pre-create the workspace in HCP Terraform to avoid the prompt.","Set `workspaces.name` explicitly in the `cloud` block.","If scripting, pipe a real name: `echo 'prod' | terraform init`."],"exampleFix":"# before: empty input at prompt\n# 'No workspaces found.' -> [Enter]\n# after\n# 'No workspaces found.' -> type 'prod' [Enter]\n# or pre-create in UI / set in config:\ncloud { organization = \"acme\" workspaces { name = \"prod\" } }","handlingStrategy":"validation","validationCode":"// Validate the prompted name before passing it on.\nname = strings.TrimSpace(name)\nif name == \"\" || !arguments.ValidWorkspaceName(name) {\n    return errors.New(\"a non-empty valid workspace name is required\")\n}","typeGuard":"func nonEmptyValidWs(s string) bool {\n    s = strings.TrimSpace(s)\n    return s != \"\" && arguments.ValidWorkspaceName(s)\n}","tryCatchPattern":"null","preventionTips":["Always type a concrete workspace name at the onboarding prompt.","Set `workspaces.name` in config to skip the prompt.","When piping input, supply a real name, not an empty line."],"tags":["terraform","cloud","workspace","input","validation","onboarding"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}