{"record":{"id":"97bee203ba84f631","repo":"kovidgoyal/kitty","slug":"no-user-record-available-for-user-with-uid-v","errorCode":null,"errorMessage":"No user record available for user with UID: %#v","messagePattern":"No user record available for user with UID: %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"tools/utils/passwd.go","lineNumber":143,"sourceCode":"})\n\nfunc LoginShellForUser(u *user.User) (ans string, err error) {\n\tvar db map[string]PasswdEntry\n\tswitch runtime.GOOS {\n\tcase \"darwin\":\n\t\tdb = dscl_user_database()\n\t\terr = dscl_error\n\tdefault:\n\t\tdb = passwd_database()\n\t\terr = passwd_err\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\tif rec, found := db[u.Uid]; found {\n\t\treturn rec.Shell, nil\n\t}\n\treturn ans, fmt.Errorf(\"No user record available for user with UID: %#v\", u.Uid)\n}\n\nfunc CurrentUser() (ans *user.User, err error) {\n\tans, err = user.Current()\n\tif err != nil && runtime.GOOS == \"darwin\" {\n\t\tuid := strconv.Itoa(os.Geteuid())\n\t\tdb := dscl_user_database()\n\t\tif dscl_error != nil {\n\t\t\terr = dscl_error\n\t\t\treturn\n\t\t}\n\t\tif rec, found := db[uid]; found {\n\t\t\tu := user.User{Uid: uid, Gid: rec.Gid, Username: rec.Username, Name: rec.Gecos, HomeDir: rec.Home}\n\t\t\tans = &u\n\t\t\terr = nil\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"Could not find the current uid: %d in the DSCL user database\", os.Geteuid())\n\t\t}","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/utils/passwd.go#L125-L161","documentation":"LoginShellForUser resolves the shell for a *user.User by looking up the user's UID in the passwd database. This error means the user struct was obtained (e.g. from user.Current or user.LookupId) but no passwd record with that UID exists in the database this library consults, so no shell can be determined.","triggerScenarios":"Calling LoginShellForUser/LoginShellForCurrentUser where the user's UID has no passwd entry: user deleted after login, LDAP/NIS user missing from the local cache, or a container user defined only in the orchestrator.","commonSituations":"macOS with directory-service lag, LDAP outages where getpwuid fails, or CI containers running as arbitrary UIDs. Typically hit when the tool tries to figure out which shell to spawn config for.","solutions":["Confirm the user record: `getent passwd $UID` / `dscl . -read /Users/$USER`.","Restart the directory service (macOS: `killall DirectoryService`/`dscl`) or refresh SSSD/nscd caches on Linux.","In containers, add the user to /etc/passwd in the image.","Fall back to a default shell such as /bin/sh when the lookup fails."],"exampleFix":"// before\nshell, err := utils.LoginShellForCurrentUser()\n// after\nshell, err := utils.LoginShellForCurrentUser()\nif err != nil {\n    shell = \"/bin/sh\"\n}","handlingStrategy":"fallback","validationCode":"if _, err := user.LookupId(strconv.Itoa(u.Uid)); err != nil {\n    // record missing; expect LoginShellForUser to fail\n}","typeGuard":null,"tryCatchPattern":"shell, err := utils.LoginShellForUser(u)\nif err != nil {\n    shell = \"/bin/sh\"\n    err = nil\n}","preventionTips":["Default to /bin/sh when shell resolution fails.","On macOS, verify DSCL with dscl . -read /Users/$USER.","Refresh SSSD/nscd caches after LDAP changes."],"tags":["go","passwd","login-shell","unix"],"backgroundTag":"user-lookup-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}