{"record":{"id":"0b43d8e1bdc32403","repo":"AdguardTeam/AdGuardHome","slug":"parsing-uid-w","errorCode":null,"errorMessage":"parsing uid: %w","messagePattern":"parsing uid: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/aghos/user_unix.go","lineNumber":39,"sourceCode":"\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":21,"sourceCodeEnd":49,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghos/user_unix.go#L21-L49","documentation":"After a successful user lookup, the Uid string failed strconv.Atoi — the user database returned a non-numeric uid. UIDs are numeric by definition, so this signals malformed system data rather than bad input.","triggerScenarios":"user.Lookup returns a User with a non-numeric Uid field — corrupted /etc/passwd, a broken NSS module, or an auth backend returning empty/malformed uid fields.","commonSituations":"Hand-edited /etc/passwd with errors; LDAP entries with invalid uidNumber attributes; essentially never occurs with a healthy user database.","solutions":["Inspect the entry: getent passwd <name> — third field must be an integer","Repair /etc/passwd or the LDAP uidNumber attribute","Defensively, prefer strconv.ParseUint and validate the range before Setuid"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"u, err := user.Lookup(name)\nif err == nil {\n    if _, err := strconv.Atoi(u.Uid); err != nil { /* malformed passwd DB */ }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate numeric uids after lookup","Lint /etc/passwd after manual edits","Verify LDAP uidNumber attributes are numeric"],"tags":["unix","uid","strconv","parse-error","os-user"],"backgroundTag":"uid-parse-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}