{"record":{"id":"daae40c6c61bdad1","repo":"hashicorp/nomad","slug":"unable-to-convert-uid-to-an-int-w","errorCode":null,"errorMessage":"Unable to convert Uid to an int: %w","messagePattern":"Unable to convert Uid to an int: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocdir/fs_unix.go","lineNumber":72,"sourceCode":"\t}\n\n\tgid, err := getGid(u)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := os.Chown(path, uid, gid); err != nil {\n\t\treturn fmt.Errorf(\"Couldn't change owner/group of %v to (uid: %v, gid: %v): %w\", path, uid, gid, err)\n\t}\n\n\treturn nil\n}\n\n// getUid for a user\nfunc getUid(u *user.User) (int, error) {\n\tuid, err := strconv.Atoi(u.Uid)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"Unable to convert Uid to an int: %w\", err)\n\t}\n\n\treturn uid, nil\n}\n\n// getGid for a user\nfunc getGid(u *user.User) (int, error) {\n\tgid, err := strconv.Atoi(u.Gid)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"Unable to convert Gid to an int: %w\", err)\n\t}\n\n\treturn gid, nil\n}\n\n// linkOrCopy attempts to hardlink dst to src and fallsback to copying if the\n// hardlink fails.\nfunc linkOrCopy(src, dst string, uid, gid int, perm os.FileMode) error {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocdir/fs_unix.go#L54-L90","documentation":"getUid converts the textual Uid field of a resolved user (os/user.User) to an int with strconv.Atoi. This error means the Uid string was not a valid integer, which normally indicates a corrupted or unusual user database entry rather than a Nomad problem. It is surfaced while dropDirPermissions resolves 'nobody'.","triggerScenarios":"strconv.Atoi(u.Uid) returned an error after users.Lookup(\"nobody\") (or another user lookup) returned a User whose Uid string is non-numeric.","commonSituations":"Manually edited /etc/passwd with a malformed uid field; NSS backends returning unexpected strings; corrupted passwd databases on the client host.","solutions":["Run `getent passwd nobody` and fix the uid field in /etc/passwd (or the NSS source) if it is not numeric.","Restore a standard passwd file on minimal/broken images.","Validate all users referenced by Nomad task configs have numeric uid/gid fields.","Restart the client after repairing the user database."],"exampleFix":"// before: malformed passwd entry\nnobody:x:unknown:65534::/nonexistent:/sbin/nologin\n// after: numeric uid\nnobody:x:65534:65534:nobody:/nonexistent:/sbin/nologin","handlingStrategy":"validation","validationCode":"// preflight: referenced users must have numeric ids\nfor _, name := range []string{\"nobody\", taskUser} {\n    u, err := user.Lookup(name)\n    if err != nil { return err }\n    if _, err := strconv.Atoi(u.Uid); err != nil {\n        return fmt.Errorf(\"user %s has non-numeric uid %q\", name, u.Uid)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := td.Build(); err != nil {\n    if strings.Contains(err.Error(), \"convert Uid to an int\") {\n        log.Printf(\"corrupt passwd entry on client host; repair /etc/passwd\")\n    }\n    return err\n}","preventionTips":["Never hand-edit /etc/passwd without validating with `vipw -s` or `pwck`.","Validate NSS-provided users return numeric uid fields.","Run pwck as part of host provisioning."],"tags":["users","parsing","linux","nomad"],"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"}