{"record":{"id":"c580e23ea27ed98a","repo":"quarkusio/quarkus","slug":"file-does-not-exist-file","errorCode":null,"errorMessage":"File does not exist: ${file}","messagePattern":"File does not exist: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/FilePart.java","lineNumber":34,"sourceCode":"     * The starting byte of the file\n     */\n    public final long offset;\n\n    /**\n     * The number of bytes to send\n     */\n    public final long count;\n\n    /**\n     * Create a new partial {@link File} object.\n     *\n     * @param file The file to send\n     * @param offset The starting byte of the file (must be >= 0)\n     * @param count The number of bytes to send (must be >= 0 and offset+count <= file size)\n     */\n    public FilePart(File file, long offset, long count) {\n        if (!file.exists())\n            throw new IllegalArgumentException(\"File does not exist: \" + file);\n        if (!file.isFile())\n            throw new IllegalArgumentException(\"File is not a regular file: \" + file);\n        if (!file.canRead())\n            throw new IllegalArgumentException(\"File cannot be read: \" + file);\n        if (offset < 0)\n            throw new IllegalArgumentException(\"Offset (\" + offset + \") must be >= 0: \" + file);\n        if (count < 0)\n            throw new IllegalArgumentException(\"Count (\" + count + \") must be >= 0: \" + file);\n        if ((offset + count) > file.length())\n            throw new IllegalArgumentException(\n                    \"Offset + count (\" + (offset + count) + \") larger than file size (\" + file.length() + \"): \" + file);\n        this.file = file;\n        this.offset = offset;\n        this.count = count;\n    }\n}\n","sourceCodeStart":16,"sourceCodeEnd":51,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/FilePart.java#L16-L51","documentation":"The FilePart(File, long, long) constructor validates its File argument before creating the part used to send a byte range of a file. If the file does not exist on the filesystem, an IllegalArgumentException is thrown immediately instead of failing later during the send.","triggerScenarios":"new FilePart(file, offset, count) where file.exists() returns false (typical first check in the validation chain).","commonSituations":"Typo or wrong relative path resolved against a different working directory; file deleted between path computation and FilePart construction; packaging a resource that was never written to disk.","solutions":["Verify the path is correct and resolve it against the intended base directory.","Create the file before constructing the FilePart (or use Files.createFile/absolute paths).","Check existence with Files.exists(Path) and fail fast with a clear application-level error."],"exampleFix":"// before\nreturn new FilePart(new File(config.path), 0, size);\n// after\nFile f = new File(config.path);\nif (!f.exists()) throw new IllegalStateException(\"Missing upload file: \" + f.getAbsolutePath());\nreturn new FilePart(f, 0, size);","handlingStrategy":"validation","validationCode":"File f = new File(path);\nif (!f.exists()) throw new IllegalStateException(\"File missing: \" + f.getAbsolutePath());\n// safe to construct now\nFilePart part = new FilePart(f, offset, count);","typeGuard":"static boolean isSendableFile(File f) {\n    return f != null && f.exists() && f.isFile() && f.canRead();\n}","tryCatchPattern":"try {\n    return new FilePart(file, offset, count);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"File does not exist\")) {\n        throw new IllegalStateException(\"Upload file missing: \" + file.getAbsolutePath(), e);\n    }\n    throw e;\n}","preventionTips":["Always log file.getAbsolutePath() to reveal wrong working directories","Check Files.exists before constructing parts","Avoid relative paths derived from assumptions about CWD"],"tags":["filesystem","io","argument-validation"],"backgroundTag":"file-not-found","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}