kestra-io/kestra · error · IllegalArgumentException
Cannot create a working directory file with a null path
Error message
Cannot create a working directory file with a null path
What it means
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.
Source
Thrown at core/src/main/java/io/kestra/core/runners/LocalWorkingDir.java:194
return newFilePath;
}
/**
* {@inheritDoc}
**/
@Override
public Path putFile(Path path, InputStream inputStream) throws IOException {
return putFile(path, inputStream, FileExistComportment.OVERWRITE);
}
/**
* {@inheritDoc}
**/
@Override
public Path putFile(Path path, InputStream inputStream, FileExistComportment comportment) throws IOException {
if (path == null) {
throw new IllegalArgumentException("Cannot create a working directory file with a null path");
}
if (inputStream == null) {
throw new IllegalArgumentException("Cannot create a working directory file with an empty inputStream");
}
Path newFilePath = this.resolve(path);
Files.createDirectories(newFilePath.getParent());
if (Files.exists(newFilePath)) {
switch (comportment) {
case OVERWRITE -> {
log.info("File {} already exist. It will be overwritten", newFilePath);
copyFile(inputStream, newFilePath);
}
case FAIL -> throw new FileAlreadyExistsException("File " + newFilePath + " already exist");
case WARN -> log.warn("File {} already exist. It will be ignore", newFilePath);
case IGNORE -> {
}
}View on GitHub (pinned to 823fada927)
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.
Example fix
// before
Path target = computedPath; // null
workingDir.putFile(target, in);
// after
if (target == null) throw new IllegalStateException("target path is null");
workingDir.putFile(target, in); Defensive patterns
Strategy: validation
Validate before calling
if (path == null) {
throw new IllegalArgumentException("Cannot putFile: path is null");
}
return workingDir.putFile(path, inputStream); Type guard
static boolean hasPath(Path p) { return p != null; } Prevention
- 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.
When it happens
Trigger: Calling `workingDir.putFile(null, stream)` or `putFile(null, stream, comportment)`. Typically the path is computed from a variable/expression that evaluated to null.
Common situations: 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.
Related errors
- Cannot create a working directory file with a null or empty
- Cannot create a working directory file with an empty inputSt
- The path to resolve must be a relative path inside the curre
- File {} already exist
- Invalid flow path
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/be256c55f443b7df.
Report an issue: GitHub.