{"record":{"id":"eef4f4ab6fd3e95e","repo":"AdguardTeam/AdGuardHome","slug":"parsing-gid-w","errorCode":null,"errorMessage":"parsing gid: %w","messagePattern":"parsing gid: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/aghos/user_unix.go","lineNumber":20,"sourceCode":"\npackage aghos\n\nimport (\n\t\"fmt\"\n\t\"os/user\"\n\t\"strconv\"\n\t\"syscall\"\n)\n\nfunc setGroup(groupName string) (err error) {\n\tg, err := user.LookupGroup(groupName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"looking up group: %w\", err)\n\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 {","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghos/user_unix.go#L2-L38","documentation":"After successfully looking up a group, its Gid string couldn't be parsed as an integer with strconv.Atoi. This indicates the group database returned a non-numeric gid — effectively malformed system data, since gids are numeric by POSIX definition.","triggerScenarios":"user.LookupGroup returns a Group whose Gid field contains garbage (non-numeric) — corrupted /etc/group, a broken NSS plugin returning empty or malformed fields, or an unusual libc/getent setup.","commonSituations":"Hand-edited /etc/group with syntax errors; exotic authentication backends (LDAP with malformed gidNumber); rarely hit in practice because most resolvers validate gids.","solutions":["Inspect the group entry: getent group <name> and check the third field is a plain integer","Repair /etc/group syntax or fix the LDAP gidNumber attribute","As a defensive measure in code, prefer strconv.ParseUint with a clearer error and validation before Setgid"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"g, err := user.LookupGroup(name)\nif err == nil {\n    if _, err := strconv.Atoi(g.Gid); err != nil { /* malformed group DB; repair host */ }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate numeric gids after lookup before calling Setgid","Keep /etc/group well-formed; lint after manual edits","Use getent to verify NSS returns sane data"],"tags":["unix","gid","strconv","parse-error","os-user"],"backgroundTag":"gid-parse-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}