kestra-io/kestra · error · IllegalArgumentException
Cannot create a working directory file with an empty inputSt
Error message
Cannot create a working directory file with an empty inputStream
What it means
Thrown by `LocalWorkingDir.putFile(Path, InputStream, ...)` when the `inputStream` argument is null (the path is non-null at this point). Writing a file requires content; a null stream is a programming error. Thrown as `IllegalArgumentException` before any filesystem operation.
Source
Thrown at core/src/main/java/io/kestra/core/runners/LocalWorkingDir.java:197
/**
* {@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 -> {
}
}
} else {
Files.createFile(newFilePath);
copyFile(inputStream, newFilePath);View on GitHub (pinned to 823fada927)
Solutions
- Ensure the input stream is non-null and open before calling `putFile`.
- If content is optional, write an empty stream (`InputStream.nullInputStream(0)`) instead of null.
- Add a null-check with a descriptive error at the call site.
Example fix
// before InputStream in = maybeStream; // null workingDir.putFile(path, in); // after InputStream in = Objects.requireNonNull(maybeStream, "content stream"); workingDir.putFile(path, in);
Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(inputStream, "Cannot putFile: inputStream is null"); return workingDir.putFile(path, inputStream);
Prevention
- Open the stream immediately before writing; do not store streams in nullable fields.
- Use `InputStream.nullInputStream(0)` for intentionally-empty content rather than null.
- Check the result of `storage().getFile(...)` for null before passing it on.
When it happens
Trigger: Calling `workingDir.putFile(path, null)` — the input stream was not opened or was already closed/passed as null. Common when a fetch/transfer operation failed silently upstream and the stream variable is null.
Common situations: A `runContext.storage().getFile(...)` that returned null; an HTTP download whose body stream was not captured; passing a closed stream reference; refactoring that dropped the stream assignment.
Related errors
- Cannot create a working directory file with a null or empty
- Cannot create a working directory file with a null path
- 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/979db34206db8bcf.
Report an issue: GitHub.