apache/hadoop · error · PathIOException
Must specify either create, overwrite or append
Error message
Must specify either create, overwrite or append
What it means
Thrown by FileSystem's FSDataOutputStreamBuilder.build when none of CREATE, OVERWRITE or APPEND is present in the builder's flags. Opening a stream requires an explicit creation mode; the builder rejects the ambiguous request.
Solutions
- Pass at least one of CreateFlag.CREATE, CreateFlag.OVERWRITE, or CreateFlag.APPEND when creating the stream.
- Review the create flags being built; an empty flag set is invalid.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:4716 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/61b020084cd77478.
Report an issue: GitHub.
Appendix: source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:4716
@Override
public FSDataOutputStream build() throws IOException {
rejectUnknownMandatoryKeys(Collections.emptySet(),
" for " + getPath());
if (getFlags().contains(CreateFlag.CREATE) ||
getFlags().contains(CreateFlag.OVERWRITE)) {
if (isRecursive()) {
return getFS().create(getPath(), getPermission(), getFlags(),
getBufferSize(), getReplication(), getBlockSize(), getProgress(),
getChecksumOpt());
} else {
return getFS().createNonRecursive(getPath(), getPermission(),
getFlags(), getBufferSize(), getReplication(), getBlockSize(),
getProgress());
}
} else if (getFlags().contains(CreateFlag.APPEND)) {
return getFS().append(getPath(), getBufferSize(), getProgress());
}
throw new PathIOException(getPath().toString(),
"Must specify either create, overwrite or append");
}
@Override
public FileSystemDataOutputStreamBuilder getThisBuilder() {
return this;
}
}
/**
* Create a new FSDataOutputStreamBuilder for the file with path.
* Files are overwritten by default.
*
* @param path file path
* @return a FSDataOutputStreamBuilder object to build the file
*
* HADOOP-14384. Temporarily reduce the visibility of method before the
* builder interface becomes stable.View on GitHub (pinned to 2add963021)