{"record":{"id":"e4860bd17d8d0654","repo":"apache/druid","slug":"cannot-have-a-comma-in-the-name-of-a-file-got-s","errorCode":null,"errorMessage":"Cannot have a comma in the name of a file, got[%s].","messagePattern":"Cannot have a comma in the name of a file, got\\[(.+?)\\]\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/io/smoosh/FileSmoosher.java","lineNumber":146,"sourceCode":"  @Override\n  public void addColumn(String name, ColumnDescriptor columnDescriptor)\n  {\n    throw DruidException.defensive(\"not supported\");\n  }\n\n  @Override\n  public void add(String name, File fileToAdd) throws IOException\n  {\n    try (MappedByteBufferHandler fileMappingHandler = FileUtils.map(fileToAdd)) {\n      add(name, fileMappingHandler.get());\n    }\n  }\n\n  @Override\n  public void add(String name, ByteBuffer bufferToAdd) throws IOException\n  {\n    if (name.contains(\",\")) {\n      throw new IAE(\"Cannot have a comma in the name of a file, got[%s].\", name);\n    }\n\n    if (internalFiles.get(name) != null) {\n      throw new IAE(\"Cannot add files of the same name, already have [%s]\", name);\n    }\n\n    long size = 0;\n    size += bufferToAdd.remaining();\n\n    try (SegmentFileChannel out = addWithChannel(name, size)) {\n      out.write(bufferToAdd);\n    }\n  }\n\n  @Override\n  public SegmentFileChannel addWithChannel(final String name, final long size) throws IOException\n  {\n    return addWithSmooshedWriter(name, size);","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/io/smoosh/FileSmoosher.java#L128-L164","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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 '-')."],"exampleFix":"// before\nsmoosher.add(fileName, buffer); // fileName = \"ds1,ds2_2020-01-01\"\n// after\nString safeName = fileName.replace(',', '_');\nsmoosher.add(safeName, buffer);","handlingStrategy":"validation","validationCode":"if (name.indexOf(',') >= 0) {\n  throw new IllegalArgumentException(\"File name must not contain a comma: \" + name);\n}\nsmoosher.add(name, buffer);","typeGuard":"static boolean isSmooshSafeName(final String name) {\n  return name != null && !name.contains(\",\");\n}","tryCatchPattern":"try {\n  smoosher.add(name, buffer);\n} catch (IllegalArgumentException e) {\n  throw new IOException(\"Invalid smoosh file name: \" + name, e);\n}","preventionTips":["Sanitize generated names (replace ',', whitespace) before writing.","Derive file names from validated identifiers only.","Add a unit test asserting names never contain commas."],"tags":["io","smoosh","file-naming","illegal-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}