{"record":{"id":"6086345be1dc3446","repo":"apache/beam","slug":"column-headers-should-be-supplied-when-delimiter-is-present-608634","errorCode":null,"errorMessage":"Column headers should be supplied when delimiter is present.","messagePattern":"Column headers should be supplied when delimiter is 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":155,"sourceCode":"\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   *\n   * @param input input PCollection\n   * @return PCollection after transformations\n   */\n  @Override","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPInspectText.java#L137-L173","documentation":"The mirror case of the delimiter/headers pairing check: DLPInspectText.build() throws this IllegalArgumentException when a columnDelimiter is supplied but headerColumns is null. A delimiter without headers leaves the structured-input configuration incomplete and ambiguous for the DLP request.","triggerScenarios":"Calling DLPInspectText.newBuilder()...setColumnDelimiter(\",\").build() without calling .setHeaderColumns(...).","commonSituations":"Developers set the delimiter for CSV parsing but forget the header list, or remove the headers while refactoring and leave the delimiter behind.","solutions":["Add .setHeaderColumns(Arrays.asList(\"col1\", \"col2\", ...)) matching your input columns.","If the input is unstructured, remove .setColumnDelimiter(...) entirely.","Validate that headers and delimiter are set together before building the transform."],"exampleFix":"// before\n.setColumnDelimiter(\",\")\n// after\n.setColumnDelimiter(\",\")\n.setHeaderColumns(Arrays.asList(\"name\", \"email\"))","handlingStrategy":"validation","validationCode":"if (columnDelimiter != null && headerColumns == null) {\n  throw new IllegalArgumentException(\"headerColumns must be supplied together with columnDelimiter\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  DLPInspectText inspect = DLPInspectText.newBuilder()...build();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Column headers should be supplied\")) {\n    // supply headerColumns or drop the delimiter and rebuild\n  }\n}","preventionTips":["Only set columnDelimiter for genuinely structured (CSV-like) input, and always with its header list.","Remove both fields together when switching to unstructured text inspection.","Model the pair as a single options object so they cannot diverge."],"tags":["java","apache-beam","google-cloud-dlp","builder-validation","csv"],"backgroundTag":"missing-required-argument","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"}