{"record":{"id":"70cadeddb9f0fce7","repo":"Billionmail/BillionMail","slug":"file-not-exists","errorCode":null,"errorMessage":"file not exists: ","messagePattern":"file not exists: ","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/public/common.go","lineNumber":1437,"sourceCode":"\n\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 ChgrpWithGidRecursive(path, gid)\n}\n\n// Change group of a file or directory with GID (recursive)\nfunc ChgrpWithGidRecursive(path string, 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\n\t\t}\n\n\t\tfor _, d := range ds {\n\t\t\terr = ChgrpWithGidRecursive(path+\"/\"+d.Name(), gid)\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":1419,"sourceCodeEnd":1455,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/public/common.go#L1419-L1455","documentation":"ChgrpWithGidRecursive recursively changes the group ownership of a path to the given GID. Before touching the filesystem it checks FileExists(path); if the path does not exist it returns \"file not exists: <path>\". The library throws this so callers get a clear pre-condition failure instead of an opaque os.Chown ENOENT error.","triggerScenarios":"Calling ChgrpWithGidRecursive(path, gid) with a path that has been deleted, renamed, is a broken symlink, or was never created (typo in path or missing mount).","commonSituations":"Deleting a user's mail directory while a background job still tries to chgrp it; relative path computed against a different working directory; container volume not mounted; typo in configured directory name.","solutions":["Verify the path exists with os.Stat or FileExists before calling","Log/print the absolute path (filepath.Abs) to spot typos and wrong working directories","Create the target path (os.MkdirAll) if it is expected to exist","Check mounts/volumes if the path is normally provided by a container or NFS"],"exampleFix":"// before\nif err := public.ChgrpWithGidRecursive(path, gid); err != nil { return err }\n// after\nif !public.FileExists(path) {\n    return fmt.Errorf(\"skip chgrp, path missing: %s\", path)\n}\nif err := public.ChgrpWithGidRecursive(path, gid); err != nil { return err }","handlingStrategy":"validation","validationCode":"func canChgrp(path string) bool {\n    _, err := os.Stat(path)\n    return err == nil\n}\nif !canChgrp(path) { return fmt.Errorf(\"path missing: %s\", path) }","typeGuard":"func pathExists(p string) bool {\n    _, err := os.Stat(p)\n    return !os.IsNotExist(err)\n}","tryCatchPattern":"if err := public.ChgrpWithGidRecursive(path, gid); err != nil {\n    if strings.HasPrefix(err.Error(), \"file not exists\") {\n        log.Warnf(\"skipping chgrp, missing path: %s\", path)\n        return nil\n    }\n    return err\n}","preventionTips":["Stat the path immediately before ownership changes","Always use absolute paths derived from a single base constant","Log path and CWD when the error occurs to catch relative-path bugs","Check volume/mount health before batch ownership jobs"],"tags":["filesystem","file-not-found","chown"],"backgroundTag":"file-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"}