apache/beam · error · IllegalArgumentException

Column headers should be supplied when delimiter is present.

Error message

Column headers should be supplied when delimiter is present.

What it means

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.

Source

Thrown at sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPInspectText.java:155

    public DLPInspectText build() {
      DLPInspectText inspectText = autoBuild();
      if (inspectText.getInspectTemplateName() == null && inspectText.getInspectConfig() == null) {
        throw new IllegalArgumentException(
            "Either inspectTemplateName or inspectConfig must be supplied!");
      }
      if (inspectText.getBatchSizeBytes() > DLP_PAYLOAD_LIMIT_BYTES) {
        throw new IllegalArgumentException(
            String.format(
                "Batch size is too large! It should be smaller or equal than %d.",
                DLP_PAYLOAD_LIMIT_BYTES));
      }
      if (inspectText.getColumnDelimiter() == null && inspectText.getHeaderColumns() != null) {
        throw new IllegalArgumentException(
            "Column delimiter should be set if headers are present.");
      }
      if (inspectText.getHeaderColumns() == null && inspectText.getColumnDelimiter() != null) {
        throw new IllegalArgumentException(
            "Column headers should be supplied when delimiter is present.");
      }
      return inspectText;
    }
  }

  public static Builder newBuilder() {
    return new AutoValue_DLPInspectText.Builder();
  }

  /**
   * The transform converts the contents of input PCollection into {@link Table.Row}s and then calls
   * Cloud DLP service to perform the data inspection according to provided settings.
   *
   * @param input input PCollection
   * @return PCollection after transformations
   */
  @Override

View on GitHub (pinned to 12126d8942)

Solutions

  1. Add .setHeaderColumns(Arrays.asList("col1", "col2", ...)) matching your input columns.
  2. If the input is unstructured, remove .setColumnDelimiter(...) entirely.
  3. Validate that headers and delimiter are set together before building the transform.

Example fix

// before
.setColumnDelimiter(",")
// after
.setColumnDelimiter(",")
.setHeaderColumns(Arrays.asList("name", "email"))
Defensive patterns

Strategy: validation

Validate before calling

if (columnDelimiter != null && headerColumns == null) {
  throw new IllegalArgumentException("headerColumns must be supplied together with columnDelimiter");
}

Try / catch

try {
  DLPInspectText inspect = DLPInspectText.newBuilder()...build();
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("Column headers should be supplied")) {
    // supply headerColumns or drop the delimiter and rebuild
  }
}

Prevention

When it happens

Trigger: Calling DLPInspectText.newBuilder()...setColumnDelimiter(",").build() without calling .setHeaderColumns(...).

Common situations: Developers set the delimiter for CSV parsing but forget the header list, or remove the headers while refactoring and leave the delimiter behind.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/6086345be1dc3446. Report an issue: GitHub.