{"record":{"id":"1011b96871cd2e4c","repo":"hashicorp/nomad","slug":"unable-to-convert-userid-s-to-integer","errorCode":null,"errorMessage":"unable to convert userid %s to integer","messagePattern":"unable to convert userid (.+?) to integer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/validators/validators_unix.go","lineNumber":17,"sourceCode":"// Copyright IBM Corp. 2015, 2026\n// SPDX-License-Identifier: MPL-2.0\n\n//go:build !windows\n\npackage validators\n\nimport (\n\t\"fmt\"\n\t\"os/user\"\n\t\"strconv\"\n)\n\nfunc getUserID(user *user.User) (UserID, error) {\n\tid, err := strconv.ParseUint(user.Uid, 10, 32)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"unable to convert userid %s to integer\", user.Uid)\n\t}\n\n\treturn UserID(id), nil\n}\n\nfunc getGroupsID(user *user.User) ([]GroupID, error) {\n\tgidStrings, err := user.GroupIds()\n\tif err != nil {\n\t\treturn []GroupID{}, fmt.Errorf(\"unable to lookup user's group membership: %w\", err)\n\t}\n\n\tgids := make([]GroupID, len(gidStrings))\n\n\tfor _, gidString := range gidStrings {\n\t\tu, err := strconv.ParseUint(gidString, 10, 32)\n\t\tif err != nil {\n\t\t\treturn []GroupID{}, fmt.Errorf(\"unable to convert user's group %q to integer: %w\", gidString, err)\n\t\t}","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/validators/validators_unix.go#L1-L35","documentation":"getUserID converts the Unix user's Uid string (from user.User) to a UserID via strconv.ParseUint. This error means the uid string on the system could not be parsed as an unsigned 32-bit integer, so the validator cannot check whether the uid is denied. It is wrapped by HasValidIDs as 'validator: ...'.","triggerScenarios":"Calling Validator.HasValidIDs(userName) on a Unix system where users.Lookup succeeds but user.Uid is empty, non-numeric, or exceeds uint32 range (e.g. a malformed /etc/passwd entry or NSS source returning a bad uid string).","commonSituations":"Broken /etc/passwd or corrupted LDAP/SSSD/AD-backed NSS entries returning garbage uid fields; containers with unusual user databases; systems where uid values exceed 2^32-1.","solutions":["Inspect the user's entry in the NSS source (getent passwd <user>) and fix the malformed uid","Repair /etc/passwd or the directory service entry for the affected user","Check that /etc/nsswitch.conf points at the intended passwd sources","If a directory service returns uids above 4294967295, remap the user to a uid within uint32 range"],"exampleFix":"// before (bad passwd entry)\nbaduser:x:abc:1000::/home/baduser:/bin/bash\n// after\nbaduser:x:15000:1000::/home/baduser:/bin/bash","handlingStrategy":"validation","validationCode":"u, err := user.Lookup(username)\nif err != nil { return err }\nif _, err := strconv.ParseUint(u.Uid, 10, 32); err != nil {\n\treturn fmt.Errorf(\"uid %q for user %s is not a valid uint32\", u.Uid, username)\n}","typeGuard":"func validUID(uid string) bool {\n\t_, err := strconv.ParseUint(uid, 10, 32)\n\treturn err == nil\n}","tryCatchPattern":null,"preventionTips":["Verify 'getent passwd <user>' returns a numeric uid before scheduling tasks as that user","Monitor NSS/directory-service health on hosts running tasks","Avoid hand-editing /etc/passwd; use useradd/usermod","Keep uids within the standard uint32 range (<= 4294967294)"],"tags":["unix","user-lookup","parsing"],"backgroundTag":"invalid-user-id","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}