{"record":{"id":"6d8ea03e9f2fc47a","repo":"Billionmail/BillionMail","slug":"source-file-directory-does-not-exist-s","errorCode":null,"errorMessage":"source file/directory does not exist: %s","messagePattern":"source file/directory does not exist: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/compress/rar.go","lineNumber":190,"sourceCode":"\t\treturn err\n\t}\n\n\t// prepare command arguments\n\targs := []string{\"a\", \"-ep1\", \"-r\"}\n\n\t// add destination file\n\targs = append(args, dstAbs)\n\n\t// validate each source and add it to command\n\tfor _, src := range srcList {\n\t\tsrcAbs, err := filepath.Abs(src)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// make sure source exists\n\t\tif _, err := os.Stat(srcAbs); err != nil {\n\t\t\treturn fmt.Errorf(\"source file/directory does not exist: %s\", src)\n\t\t}\n\n\t\t// add source to arguments\n\t\targs = append(args, srcAbs)\n\t}\n\n\t// create command\n\tcmd := exec.Command(\"rar\", args...)\n\n\t// run command\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"rar compression failed: %s - %s\", err, string(output))\n\t}\n\n\t// verify the file was created\n\tif _, err := os.Stat(dstAbs); err != nil {\n\t\treturn errors.New(\"rar file was not created successfully\")","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/compress/rar.go#L172-L208","documentation":"Before adding each source to the rar command's argument list, Compress stats the absolute source path. If os.Stat fails (missing file/directory or a permission error surfaced as ENOENT), it reports the original source string in this error and aborts the whole compression.","triggerScenarios":"Calling RarUnpacker.Compress(dst, srcList...) where any entry in srcList does not exist at the given path — typo'd path, file deleted between listing and compression, wrong working directory for a relative path, or a symlink to a missing target.","commonSituations":"Relative paths used with a different cwd in a daemon vs. shell; temp files cleaned up before compression; case-sensitivity mismatch (Windows-built path on Linux).","solutions":["Check each source exists with os.Stat before calling Compress and fix/omit missing entries","Use absolute paths (filepath.Abs) instead of relying on the process working directory","Verify symlinks resolve to existing targets","Fix path casing/encoding if the archive job runs on a case-sensitive filesystem"],"exampleFix":"// before\nerr := r.Compress(\"out.rar\", \"logs/app.log\") // cwd differs in service\n// after\nsrc, _ := filepath.Abs(\"logs/app.log\")\nif _, err := os.Stat(src); err != nil { log.Fatal(err) }\nerr := r.Compress(\"out.rar\", src)","handlingStrategy":"validation","validationCode":"for _, src := range srcList {\n\tabs, err := filepath.Abs(src)\n\tif err != nil { return err }\n\tif _, err := os.Stat(abs); err != nil {\n\t\treturn fmt.Errorf(\"source missing: %s\", src)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := r.Compress(dst, srcList...); err != nil {\n\tvar missing string\n\tif _, e := fmt.Sscanf(err.Error(), \"source file/directory does not exist: %s\", &missing); e == nil {\n\t\tlog.Printf(\"skipping job, missing source: %s\", missing)\n\t}\n}","preventionTips":["os.Stat every source before scheduling compression","Use absolute paths; do not depend on process cwd","Resolve and verify symlinks before archiving","Re-list source files immediately before the job to avoid races with cleanup"],"tags":["go","compression","rar","file-not-found","path-validation"],"backgroundTag":"source-file-not-found","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}