apache/beam · error · IllegalArgumentException

Column delimiter should be set if headers are present.

Error message

Column delimiter should be set if headers are present.

What it means

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.

Source

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

     */
    public abstract Builder setHeaderColumns(PCollectionView<List<String>> headerColumns);

    abstract DLPInspectText autoBuild();

    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.
   *

View on GitHub (pinned to 12126d8942)

Solutions

  1. Add .setColumnDelimiter(",") (or the actual delimiter of your data) alongside setHeaderColumns.
  2. If the input is unstructured text, remove setHeaderColumns since headers are not needed.
  3. Validate in code that delimiter and headers are either both set or both absent before building.

Example fix

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

Strategy: validation

Validate before calling

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

Try / catch

try {
  DLPInspectText inspect = DLPInspectText.newBuilder()...build();
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("Column delimiter should be set")) {
    // set a delimiter (default ",") and rebuild
  }
}

Prevention

When it happens

Trigger: Calling DLPInspectText.newBuilder()...setHeaderColumns(List<String>).build() (or with a batchSize) without calling .setColumnDelimiter(String).

Common situations: 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.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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