{"record":{"id":"280bb16720f9a359","repo":"mislav/hub","slug":"missing-user","errorCode":null,"errorMessage":"missing user","messagePattern":"missing user","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"github/config.go","lineNumber":62,"sourceCode":"\ttokenFromEnv := token != \"\"\n\n\tif host != GitHubHost {\n\t\tif _, e := url.Parse(\"https://\" + host); e != nil {\n\t\t\terr = fmt.Errorf(\"invalid hostname: %q\", host)\n\t\t\treturn\n\t\t}\n\t}\n\n\th = c.Find(host)\n\tif h != nil {\n\t\tif h.User == \"\" {\n\t\t\tutils.Check(CheckWriteable(configsFile()))\n\t\t\t// User is missing from the config: this is a broken config probably\n\t\t\t// because it was created with an old (broken) version of hub. Let's fix\n\t\t\t// it now. See issue #1007 for details.\n\t\t\tuser := c.PromptForUser(host)\n\t\t\tif user == \"\" {\n\t\t\t\tutils.Check(fmt.Errorf(\"missing user\"))\n\t\t\t}\n\t\t\th.User = user\n\t\t\terr := newConfigService().Save(configsFile(), c)\n\t\t\tutils.Check(err)\n\t\t}\n\t\tif tokenFromEnv {\n\t\t\th.AccessToken = token\n\t\t} else {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\th = &Host{\n\t\t\tHost:        host,\n\t\t\tAccessToken: token,\n\t\t\tProtocol:    \"https\",\n\t\t}\n\t\tc.Hosts = append(c.Hosts, h)\n\t}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/github/config.go#L44-L80","documentation":"During PromptForHost, when the existing config entry for the host has no user (a config written by an old broken hub version, issue #1007), hub tries to fix it by prompting for a user. If the prompt yields an empty string, utils.Check panics/exits with this error. It indicates an unrepairable interactive-prompt situation (typically non-interactive stdin).","triggerScenarios":"PromptForHost loads an existing host entry whose User field is empty, calls PromptForUser, and the user's answer is empty (e.g. piped/empty stdin in scripts or CI).","commonSituations":"Legacy ~/.config/hub files migrated from old hub versions lacking a user line; running hub in CI where stdin provides no input; user just pressing Enter at the username prompt.","solutions":["Manually add the `user: <username>` line under the host entry in ~/.config/hub.","Delete the broken host entry from ~/.config/hub and re-run hub interactively to regenerate it.","Ensure the command runs with an interactive TTY, or provide the username via stdin when scripting.","Upgrade hub so configs are written correctly going forward."],"exampleFix":"// before (~/.config/hub)\ngithub.com:\n- oauth_token: xxxx\n// after\ngithub.com:\n- user: octocat\n  oauth_token: xxxx","handlingStrategy":"validation","validationCode":"cfg, _ := hub.Config()\nhost := cfg.Find(\"github.com\")\nif host != nil && host.User == \"\" {\n    // repair the config before running commands\n    host.User = os.Getenv(\"GITHUB_USER\")\n    err := newConfigService().Save(configsFile(), cfg)\n    if err != nil { log.Fatal(err) }\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if fmt.Sprint(r) == \"missing user\" {\n            fmt.Fprintln(os.Stderr, \"Add `user: <name>` to ~/.config/hub or run hub interactively\")\n            os.Exit(1)\n        }\n        panic(r)\n    }\n}()","preventionTips":["Ensure ~/.config/hub has a `user:` line for every host entry","Run hub once in an interactive terminal so prompts can complete","After migrating from old hub versions, verify and repair the config manually"],"tags":["configuration","prompt","interactive","migration"],"backgroundTag":"missing-config-user","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}