{"record":{"id":"d5746e5bef9fdea3","repo":"apache/beam","slug":"either-deidentifyconfig-or-deidentifytemplatename-need-to-be","errorCode":null,"errorMessage":"Either deidentifyConfig or deidentifyTemplateName need to be set!","messagePattern":"Either deidentifyConfig or deidentifyTemplateName need to be set!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPDeidentifyText.java","lineNumber":163,"sourceCode":"     */\n    public abstract Builder setInspectConfig(InspectConfig inspectConfig);\n\n    /**\n     * Sets configuration object for data deidentification. If present, supersedes the template\n     * settings.\n     *\n     * @param deidentifyConfig Configuration object for data deidentification. If present,\n     *     supersedes the template settings.\n     */\n    public abstract Builder setDeidentifyConfig(DeidentifyConfig deidentifyConfig);\n\n    abstract DLPDeidentifyText autoBuild();\n\n    public DLPDeidentifyText build() {\n      DLPDeidentifyText dlpDeidentifyText = autoBuild();\n      if (dlpDeidentifyText.getDeidentifyConfig() == null\n          && dlpDeidentifyText.getDeidentifyTemplateName() == null) {\n        throw new IllegalArgumentException(\n            \"Either deidentifyConfig or deidentifyTemplateName need to be set!\");\n      }\n      if (dlpDeidentifyText.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 (dlpDeidentifyText.getColumnDelimiter() == null\n          && dlpDeidentifyText.getHeaderColumns() != null) {\n        throw new IllegalArgumentException(\n            \"Column delimiter should be set if headers are present.\");\n      }\n      if (dlpDeidentifyText.getHeaderColumns() == null\n          && dlpDeidentifyText.getColumnDelimiter() != null) {\n        throw new IllegalArgumentException(\n            \"Column headers should be supplied when delimiter is present.\");\n      }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPDeidentifyText.java#L145-L181","documentation":"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.","triggerScenarios":"Calling DLPDeidentifyText.newBuilder()...build() without calling setDeidentifyConfig(...) or setDeidentifyTemplateName(...).","commonSituations":"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.","solutions":["Set a stored template: .setDeidentifyTemplateName(\"projects/YOUR_PROJECT/locations/.../deidentifyTemplates/ID\").","Or provide an inline config: .setDeidentifyConfig(DeidentifyConfig.newBuilder()...build()).","Validate pipeline options that supply the template name before building."],"exampleFix":"// before\nDLPDeidentifyText.newBuilder().setProjectId(pid).build(); // throws\n// after\nDLPDeidentifyText.newBuilder().setProjectId(pid)\n    .setDeidentifyTemplateName(\"projects/p/locations/us/deidentifyTemplates/t1\")\n    .build();","handlingStrategy":"validation","validationCode":"if (deidentifyConfig == null && deidentifyTemplateName == null) throw new IllegalArgumentException(\"Set deidentifyConfig or deidentifyTemplateName\");","typeGuard":null,"tryCatchPattern":"try { DLPDeidentifyText.newBuilder()...build(); } catch (IllegalArgumentException e) { /* supply config/template and rebuild */ }","preventionTips":["Provide either inline config or a template name in pipeline options","Fail fast at option-parsing time","Keep template names in validated config, not hardcoded"],"tags":["java","dlp","google-cloud","builder-validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}