{"record":{"id":"b5a17bc8db3e42ee","repo":"AdguardTeam/AdGuardHome","slug":"looking-up-user-w","errorCode":null,"errorMessage":"looking up user: %w","messagePattern":"looking up user: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/aghos/user_unix.go","lineNumber":34,"sourceCode":"\t}\n\n\tgid, err := strconv.Atoi(g.Gid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing gid: %w\", err)\n\t}\n\n\terr = syscall.Setgid(gid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"setting gid: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc setUser(userName string) (err error) {\n\tu, err := user.Lookup(userName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"looking up user: %w\", err)\n\t}\n\n\tuid, err := strconv.Atoi(u.Uid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing uid: %w\", err)\n\t}\n\n\terr = syscall.Setuid(uid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"setting uid: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":16,"sourceCodeEnd":49,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghos/user_unix.go#L16-L49","documentation":"setUser resolves a username via os/user.Lookup before calling syscall.Setuid; this error means the lookup failed — typically user.UnknownUserError (no such user) or a backend failure reading the user database.","triggerScenarios":"Configuring AdGuardHome with a user: value that doesn't exist on the host or inside the container image; NSS/LDAM lookup failures; CGO-disabled builds parsing /etc/passwd directly encountering malformed content.","commonSituations":"Typos in the username in config; minimal Docker images without the user; LDAP environments invisible to the pure-Go resolver; usernames with trailing whitespace from YAML formatting.","solutions":["Verify the user exists: getent passwd <name>","Fix the typo or create the user, then restart","In containers, create the user in the Dockerfile or use docker --user with a numeric uid","Trim whitespace in the config value and re-check spelling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := user.Lookup(userName); err != nil { /* fix config: user missing on this host */ }","typeGuard":"func isUnknownUser(err error) bool { var e user.UnknownUserError; return errors.As(err, &e) }","tryCatchPattern":"if err != nil {\n    var unknown user.UnknownUserError\n    if errors.As(err, &unknown) { /* correct username or create user */ }\n}","preventionTips":["Validate configured usernames at startup","Create users in container images or use numeric uids","Trim whitespace from config values"],"tags":["unix","user","lookup","setuid","os-user"],"backgroundTag":"user-lookup-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}