apache/druid · error · IllegalArgumentException
Cannot have a comma in the name of a file, got
Error message
Cannot have a comma in the name of a file, got[%s].
What it means
FileSmoosher writes multiple named buffers into a Smoosh 'meta.smoosh' container file, and it uses commas in the internally written file list to delimit entries. Because of that, any file name containing a comma would corrupt the container's metadata, so add() rejects such names up front with this IllegalArgumentException.
Solutions
- Sanitize the file name before calling add(): replace or strip commas (e.g. name.replace(',', '_')).
- Ensure upstream segment identifiers/data source names cannot contain commas (validate at ingestion config time).
- If many parts must be encoded in a name, use a delimiter that is legal (e.g. '_' or '-').
Example fix
// before
smoosher.add(fileName, buffer); // fileName = "ds1,ds2_2020-01-01"
// after
String safeName = fileName.replace(',', '_');
smoosher.add(safeName, buffer); Defensive patterns
Strategy: validation
Validate before calling
if (name.indexOf(',') >= 0) {
throw new IllegalArgumentException("File name must not contain a comma: " + name);
}
smoosher.add(name, buffer); Type guard
static boolean isSmooshSafeName(final String name) {
return name != null && !name.contains(",");
} Try / catch
try {
smoosher.add(name, buffer);
} catch (IllegalArgumentException e) {
throw new IOException("Invalid smoosh file name: " + name, e);
} Prevention
- Sanitize generated names (replace ',', whitespace) before writing.
- Derive file names from validated identifiers only.
- Add a unit test asserting names never contain commas.
When it happens
Trigger: Calling FileSmoosher.add(String name, ByteBuffer bufferToAdd) (directly or via addWithChannel/write) with a name containing a ',' character, e.g. a segment identifier or generated file name that embeds a comma-separated list.
Common situations: Building segment files where the segment id or data source name contains a comma; concatenating dimension values or partition keys into a file name without sanitizing; copying names from CSV input.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Cannot add files of the same name, already have
- A-Not-B requires at least 1 sketch
- BloomKFilters are not compatible for merging. this
- Bucket index out of range (0, )
- Caching is not supported. Check `isCacheable` before…
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/e4860bd17d8d0654.
Report an issue: GitHub.
Appendix: source
Thrown at processing/src/main/java/org/apache/druid/java/util/common/io/smoosh/FileSmoosher.java:146
@Override
public void addColumn(String name, ColumnDescriptor columnDescriptor)
{
throw DruidException.defensive("not supported");
}
@Override
public void add(String name, File fileToAdd) throws IOException
{
try (MappedByteBufferHandler fileMappingHandler = FileUtils.map(fileToAdd)) {
add(name, fileMappingHandler.get());
}
}
@Override
public void add(String name, ByteBuffer bufferToAdd) throws IOException
{
if (name.contains(",")) {
throw new IAE("Cannot have a comma in the name of a file, got[%s].", name);
}
if (internalFiles.get(name) != null) {
throw new IAE("Cannot add files of the same name, already have [%s]", name);
}
long size = 0;
size += bufferToAdd.remaining();
try (SegmentFileChannel out = addWithChannel(name, size)) {
out.write(bufferToAdd);
}
}
@Override
public SegmentFileChannel addWithChannel(final String name, final long size) throws IOException
{
return addWithSmooshedWriter(name, size);View on GitHub (pinned to 9b90983fd2)