{"record":{"id":"26692f4848bc3608","repo":"Billionmail/BillionMail","slug":"user-not-exists","errorCode":null,"errorMessage":"user not exists: ","messagePattern":"user not exists: ","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/public/common.go","lineNumber":1482,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\tgid := gconv.Int(grp.Gid)\n\n\tif gid < 1 {\n\t\treturn errors.New(\"group not exists: \" + groupName)\n\t}\n\n\treturn os.Chown(path, -1, gid)\n}\n\n// Change owner of a file or directory (recursive)\nfunc Chown(path, username string) error {\n\tuid, gid := GetUidAndGid(username)\n\n\tif uid == 0 || gid == 0 {\n\t\treturn errors.New(\"user not exists: \" + username)\n\t}\n\n\treturn ChownWithUidAndGidRecursive(path, uid, gid)\n}\n\n// Change owner of a file or directory with UID and GID (recursive)\nfunc ChownWithUidAndGidRecursive(path string, uid, gid int) error {\n\t// File does not exist\n\tif !FileExists(path) {\n\t\treturn errors.New(\"file not exists: \" + path)\n\t}\n\n\t// Directory\n\tif IsDir(path) {\n\t\tds, err := os.ReadDir(path)\n\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":1464,"sourceCodeEnd":1500,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/public/common.go#L1464-L1500","documentation":"Chown resolves the username via GetUidAndGid (os/user Lookup). If lookup fails or resolves to uid==0 or gid==0, it returns \"user not exists: <username>\". The zero-check also (perhaps unintentionally) rejects root, since root has UID/GID 0.","triggerScenarios":"Calling Chown(path, username) where the username does not exist on the host, the user DB (LDAP/NSS) is unreachable, or the username is \"root\" (uid/gid 0 is treated as not-found).","commonSituations":"Config references a service user (e.g. www, vmail) that was never created in the container; user exists only in the host but not inside the Docker image; root ownership intended but blocked by the zero check.","solutions":["Create the user on the system (useradd) or fix the username in config","If root is intended, call ChownWithUidAndGidRecursive(path, 0, 0) directly","Check NSS/LDAP configuration if the user exists but lookups fail inside the container"],"exampleFix":"// before\npublic.Chown(dir, \"root\") // rejected: uid/gid are 0\n// after\npublic.ChownWithUidAndGidRecursive(dir, 0, 0) // explicit chown to root\n","handlingStrategy":"validation","validationCode":"func userResolvable(name string) bool {\n    uid, gid := public.GetUidAndGid(name)\n    return uid != 0 || gid != 0\n}","typeGuard":"func isValidUser(name string) bool {\n    _, err := user.Lookup(name)\n    return err == nil && name != \"root\"\n}","tryCatchPattern":"if err := public.Chown(path, username); err != nil {\n    if strings.Contains(err.Error(), \"user not exists\") {\n        return fmt.Errorf(\"system user %q missing on this host; run provisioning\", username)\n    }\n    return err\n}","preventionTips":["Provision system users in Dockerfiles/entrypoint before app start","Validate configured usernames at startup, fail fast","Remember uid/gid 0 (root) is rejected; use the UID/GID API for root","Verify NSS/LDAP availability inside containers"],"tags":["filesystem","unix-users","chown"],"backgroundTag":"user-or-group-not-found","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}