{"record":{"id":"bfa96de97088f79b","repo":"hashicorp/nomad","slug":"failed-to-get-current-user-w","errorCode":null,"errorMessage":"failed to get current user: %w","messagePattern":"failed to get current user: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/rawexec/driver_unix.go","lineNumber":23,"sourceCode":"\npackage rawexec\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/hashicorp/nomad/helper/users\"\n\t\"github.com/hashicorp/nomad/plugins/drivers\"\n)\n\nfunc (d *Driver) Validate(cfg drivers.TaskConfig) error {\n\tusernameToLookup := cfg.User\n\n\t// Uses the current user of the client agent process\n\t// if no override is given (differs from exec)\n\tif usernameToLookup == \"\" {\n\t\tuser, err := users.Current()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get current user: %w\", err)\n\t\t}\n\n\t\tusernameToLookup = user.Username\n\t}\n\n\treturn d.userIDValidator.HasValidIDs(usernameToLookup)\n}\n","sourceCodeStart":5,"sourceCodeEnd":31,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/rawexec/driver_unix.go#L5-L31","documentation":"raw_exec's Validate (unlike exec driver) runs tasks as the current client user unless a user override is given. When no override is set, it calls users.Current(); if that OS lookup fails, Validate returns 'failed to get current user', aborting task validation before start.","triggerScenarios":"StartTask/Validate with an empty task user override on a system where the current-UID lookup fails — e.g. no passwd entry for the running UID, restricted NSS, or a container/client environment without proper user database access.","commonSituations":"Nomad client running as a UID missing from /etc/passwd (containerized clients); broken nsswitch/sssd in hardened environments; Windows lookup failures for service accounts.","solutions":["Ensure the UID the Nomad client runs as has a valid entry in the user database (/etc/passwd) or equivalent","Explicitly set the task's 'user' in the job so the current-user lookup path is skipped","Fix NSS configuration (nsswitch.conf, sssd) so user lookups resolve","Run the Nomad client as a well-known system account"],"exampleFix":"// job spec before\nuser = \"\"\n// after\nuser = \"nomad-task\"","handlingStrategy":"validation","validationCode":"u, err := users.Current()\nif err != nil {\n    // fix user database/NSS before starting tasks with empty user override\n}\nif taskUser == \"\" { taskUser = u.Username }","typeGuard":null,"tryCatchPattern":"if err := driver.Validate(taskCfg); err != nil {\n    if strings.Contains(err.Error(), \"failed to get current user\") {\n        // check /etc/passwd entry for the client UID or set explicit task user\n    }\n}","preventionTips":["Set an explicit 'user' in task config on hardened/containerized clients","Verify the Nomad client UID resolves in the user database","Keep NSS configuration (nsswitch.conf) functional on the host"],"tags":["user-lookup","validation","unix","nomad","rawexec"],"backgroundTag":"user-lookup-failed","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"}