apache/beam · error · IllegalArgumentException

Either deidentifyConfig or deidentifyTemplateName need to…

Error message

Either deidentifyConfig or deidentifyTemplateName need to be set!

What it means

DLPDeidentifyText.Builder.build validates that a de-identification strategy exists: either an inline DeidentifyConfig or a reference to a stored deidentifyTemplateName must be set. If both are null the DLP service would have nothing to execute, so build throws IllegalArgumentException.

Solutions

  1. Set a stored template: .setDeidentifyTemplateName("projects/YOUR_PROJECT/locations/.../deidentifyTemplates/ID").
  2. Or provide an inline config: .setDeidentifyConfig(DeidentifyConfig.newBuilder()...build()).
  3. Validate pipeline options that supply the template name before building.

Example fix

// before
DLPDeidentifyText.newBuilder().setProjectId(pid).build(); // throws
// after
DLPDeidentifyText.newBuilder().setProjectId(pid)
    .setDeidentifyTemplateName("projects/p/locations/us/deidentifyTemplates/t1")
    .build();
Defensive patterns

Strategy: validation

Validate before calling

if (deidentifyConfig == null && deidentifyTemplateName == null) throw new IllegalArgumentException("Set deidentifyConfig or deidentifyTemplateName");

Try / catch

try { DLPDeidentifyText.newBuilder()...build(); } catch (IllegalArgumentException e) { /* supply config/template and rebuild */ }

Prevention

When it happens

Trigger: Calling DLPDeidentifyText.newBuilder()...build() without calling setDeidentifyConfig(...) or setDeidentifyTemplateName(...).

Common situations: Forgetting to configure the DLP template path; assuming a project default template is picked up automatically; copy-pasting a builder chain and deleting the config line.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPDeidentifyText.java:163

     */
    public abstract Builder setInspectConfig(InspectConfig inspectConfig);

    /**
     * Sets configuration object for data deidentification. If present, supersedes the template
     * settings.
     *
     * @param deidentifyConfig Configuration object for data deidentification. If present,
     *     supersedes the template settings.
     */
    public abstract Builder setDeidentifyConfig(DeidentifyConfig deidentifyConfig);

    abstract DLPDeidentifyText autoBuild();

    public DLPDeidentifyText build() {
      DLPDeidentifyText dlpDeidentifyText = autoBuild();
      if (dlpDeidentifyText.getDeidentifyConfig() == null
          && dlpDeidentifyText.getDeidentifyTemplateName() == null) {
        throw new IllegalArgumentException(
            "Either deidentifyConfig or deidentifyTemplateName need to be set!");
      }
      if (dlpDeidentifyText.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 (dlpDeidentifyText.getColumnDelimiter() == null
          && dlpDeidentifyText.getHeaderColumns() != null) {
        throw new IllegalArgumentException(
            "Column delimiter should be set if headers are present.");
      }
      if (dlpDeidentifyText.getHeaderColumns() == null
          && dlpDeidentifyText.getColumnDelimiter() != null) {
        throw new IllegalArgumentException(
            "Column headers should be supplied when delimiter is present.");
      }

View on GitHub (pinned to 12126d8942)