{"record":{"id":"16f8ed57df8717d5","repo":"apache/beam","slug":"column-delimiter-should-be-set-if-headers-are-present-16f8ed","errorCode":null,"errorMessage":"Column delimiter should be set if headers are present.","messagePattern":"Column delimiter should be set if headers are present\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPInspectText.java","lineNumber":151,"sourceCode":"     */\n    public abstract Builder setHeaderColumns(PCollectionView<List<String>> headerColumns);\n\n    abstract DLPInspectText autoBuild();\n\n    public DLPInspectText build() {\n      DLPInspectText inspectText = autoBuild();\n      if (inspectText.getInspectTemplateName() == null && inspectText.getInspectConfig() == null) {\n        throw new IllegalArgumentException(\n            \"Either inspectTemplateName or inspectConfig must be supplied!\");\n      }\n      if (inspectText.getBatchSizeBytes() > DLP_PAYLOAD_LIMIT_BYTES) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"Batch size is too large! It should be smaller or equal than %d.\",\n                DLP_PAYLOAD_LIMIT_BYTES));\n      }\n      if (inspectText.getColumnDelimiter() == null && inspectText.getHeaderColumns() != null) {\n        throw new IllegalArgumentException(\n            \"Column delimiter should be set if headers are present.\");\n      }\n      if (inspectText.getHeaderColumns() == null && inspectText.getColumnDelimiter() != null) {\n        throw new IllegalArgumentException(\n            \"Column headers should be supplied when delimiter is present.\");\n      }\n      return inspectText;\n    }\n  }\n\n  public static Builder newBuilder() {\n    return new AutoValue_DLPInspectText.Builder();\n  }\n\n  /**\n   * The transform converts the contents of input PCollection into {@link Table.Row}s and then calls\n   * Cloud DLP service to perform the data inspection according to provided settings.\n   *","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPInspectText.java#L133-L169","documentation":"When DLPInspectText is given headerColumns (for CSV-like structured input) the builder also requires a columnDelimiter so rows can be parsed into columns before inspection. build() throws this IllegalArgumentException when headerColumns is set but columnDelimiter is null.","triggerScenarios":"Calling DLPInspectText.newBuilder()...setHeaderColumns(List<String>).build() (or with a batchSize) without calling .setColumnDelimiter(String).","commonSituations":"Developers supply CSV headers assuming a comma delimiter is implied by default, or set headers in one place and the delimiter in a config branch that never executes.","solutions":["Add .setColumnDelimiter(\",\") (or the actual delimiter of your data) alongside setHeaderColumns.","If the input is unstructured text, remove setHeaderColumns since headers are not needed.","Validate in code that delimiter and headers are either both set or both absent before building."],"exampleFix":"// before\n.setHeaderColumns(Arrays.asList(\"name\", \"email\"))\n// after\n.setHeaderColumns(Arrays.asList(\"name\", \"email\"))\n.setColumnDelimiter(\",\")","handlingStrategy":"validation","validationCode":"if (headerColumns != null && columnDelimiter == null) {\n  throw new IllegalArgumentException(\"columnDelimiter must be set together with headerColumns\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  DLPInspectText inspect = DLPInspectText.newBuilder()...build();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Column delimiter should be set\")) {\n    // set a delimiter (default \",\") and rebuild\n  }\n}","preventionTips":["Treat headerColumns and columnDelimiter as one atomic config unit; set them together.","Default the delimiter to \",\" for CSV inputs in your pipeline configuration layer.","Add a pre-build validation helper shared by all DLP transforms."],"tags":["java","apache-beam","google-cloud-dlp","builder-validation","csv"],"backgroundTag":"conflicting-config-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}