{"record":{"id":"8242e6b0cd2fedef","repo":"apache/druid","slug":"cannot-have-a-comma-in-the-name-of-a-file-got-s-8242e6","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/segment/file/SegmentFileBuilderV10.java","lineNumber":200,"sourceCode":"          position += transferred;\n        }\n      }\n    }\n  }\n\n  @Override\n  public void add(String name, ByteBuffer bufferToAdd) throws IOException\n  {\n    try (SegmentFileChannel out = addWithChannel(name, bufferToAdd.remaining())) {\n      out.write(bufferToAdd);\n    }\n  }\n\n  @Override\n  public SegmentFileChannel addWithChannel(final String name, final long size) 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    if (internalFiles.containsKey(name)) {\n      throw new IAE(\"Cannot add files of the same name, already have [%s]\", name);\n    }\n    ensureNameMatchesActiveBundle(name);\n    if (size > maxContainerSize) {\n      throw DruidException.forPersona(DruidException.Persona.ADMIN)\n                          .ofCategory(DruidException.Category.RUNTIME_FAILURE)\n                          .build(\n                              \"Serialized buffer size[%,d] for column[%s] exceeds the maximum[%,d]. \"\n                              + \"Consider adjusting the tuningConfig - for example, reduce maxRowsPerSegment, \"\n                              + \"or partition your data further.\",\n                              size, name, maxContainerSize\n                          );\n    }\n\n    // If an outer writer is mid-write we can't append to the current container concurrently, route through a temp\n    // file that will be merged back into a container once the outer writer releases.","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/file/SegmentFileBuilderV10.java#L182-L218","documentation":"SegmentFileBuilderV10 uses commas internally to delimit file names inside a container file, so a name containing ',' is rejected with this IllegalArgumentException in addWithChannel. This keeps the container manifest unambiguous. Callers must use comma-free internal file names (e.g. column and index file names).","triggerScenarios":"Calling SegmentFileBuilderV10.addWithChannel(name, size) or add(name, file) where the name string contains a comma character, e.g. a column name or derived file name built from user data containing ','.","commonSituations":"Programmatically generating column/file names from unescaped user input or CSV-derived names; passing a filename from a config that contains commas.","solutions":["Sanitize or encode the file name to remove commas before calling addWithChannel (e.g. replace ',' with an escape sequence)","Use Druid's FileNameUtils/StringUtils encode helper or a URL-encoding step for names derived from data","Reject the bad name earlier at ingestion time with a clear validation error so it never reaches the builder"],"exampleFix":"// before\nbuilder.addWithChannel(columnName + \".v1\", size);\n// after\nString safeName = columnName.replace(\",\", \"_%2C_\");\nbuilder.addWithChannel(safeName + \".v1\", size);","handlingStrategy":"validation","validationCode":"// Java: reject comma-containing names before calling the builder\nif (name.contains(\",\")) { throw new IllegalArgumentException(\"comma in name: \" + name); }","typeGuard":"String sanitizeFileName(String name) {\n  return name.contains(\",\") ? name.replace(\",\", \"%2C\") : name;\n}","tryCatchPattern":"try {\n  builder.addWithChannel(name, size);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Cannot have a comma\")) {\n    builder.addWithChannel(sanitizeFileName(name), size);\n  } else { throw e; }\n}","preventionTips":["Validate all generated internal file names against [a-zA-Z0-9._-] before building segments","Never derive container file names directly from user data without encoding","Add a unit test asserting no generated file name contains commas"],"tags":["validation","segment-files","naming"],"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"}