{"record":{"id":"be256c55f443b7df","repo":"kestra-io/kestra","slug":"cannot-create-a-working-directory-file-with-a-null-be256c","errorCode":null,"errorMessage":"Cannot create a working directory file with a null path","messagePattern":"Cannot create a working directory file with a null path","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/LocalWorkingDir.java","lineNumber":194,"sourceCode":"\n        return newFilePath;\n    }\n\n    /**\n     * {@inheritDoc}\n     **/\n    @Override\n    public Path putFile(Path path, InputStream inputStream) throws IOException {\n        return putFile(path, inputStream, FileExistComportment.OVERWRITE);\n    }\n\n    /**\n     * {@inheritDoc}\n     **/\n    @Override\n    public Path putFile(Path path, InputStream inputStream, FileExistComportment comportment) throws IOException {\n        if (path == null) {\n            throw new IllegalArgumentException(\"Cannot create a working directory file with a null path\");\n        }\n        if (inputStream == null) {\n            throw new IllegalArgumentException(\"Cannot create a working directory file with an empty inputStream\");\n        }\n        Path newFilePath = this.resolve(path);\n        Files.createDirectories(newFilePath.getParent());\n\n        if (Files.exists(newFilePath)) {\n            switch (comportment) {\n                case OVERWRITE -> {\n                    log.info(\"File {} already exist. It will be overwritten\", newFilePath);\n                    copyFile(inputStream, newFilePath);\n                }\n                case FAIL -> throw new FileAlreadyExistsException(\"File \" + newFilePath + \" already exist\");\n                case WARN -> log.warn(\"File {} already exist. It will be ignore\", newFilePath);\n                case IGNORE -> {\n                }\n            }","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/LocalWorkingDir.java#L176-L212","documentation":"Thrown by `LocalWorkingDir.putFile(Path, InputStream, ...)` when the `path` argument is null. `putFile` writes a stream to a path inside the working directory; a null path is a programming error. Thrown as `IllegalArgumentException` before any filesystem operation.","triggerScenarios":"Calling `workingDir.putFile(null, stream)` or `putFile(null, stream, comportment)`. Typically the path is computed from a variable/expression that evaluated to null.","commonSituations":"A filename derived from a Pebble expression that returned null; a refactor that changed the type flowing into `putFile`; test code passing a literal null.","solutions":["Ensure the path is non-null before calling `putFile`; derive it from a validated filename.","Use `createFile(filename, stream)` when you have a name rather than a Path.","Add a null-check at the call site with a clear error."],"exampleFix":"// before\nPath target = computedPath; // null\nworkingDir.putFile(target, in);\n\n// after\nif (target == null) throw new IllegalStateException(\"target path is null\");\nworkingDir.putFile(target, in);","handlingStrategy":"validation","validationCode":"if (path == null) {\n    throw new IllegalArgumentException(\"Cannot putFile: path is null\");\n}\nreturn workingDir.putFile(path, inputStream);","typeGuard":"static boolean hasPath(Path p) { return p != null; }","tryCatchPattern":null,"preventionTips":["Derive the path from a validated filename via `workingDir.resolve(Path.of(name))`.","Add explicit null-checks at call sites with descriptive messages.","Prefer `createFile(name, stream)` when you start from a name."],"tags":["working-dir","io","validation","null-check"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}