{"record":{"id":"52571e5ed9ee313b","repo":"apache/beam","slug":"either-reidentifyconfig-or-reidentifytemplatename-need-to-be","errorCode":null,"errorMessage":"Either reidentifyConfig or reidentifyTemplateName need to be set!","messagePattern":"Either reidentifyConfig or reidentifyTemplateName 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/DLPReidentifyText.java","lineNumber":168,"sourceCode":"     *\n     * @param delimiter Delimiter to be used when splitting values from input strings into columns.\n     */\n    public abstract Builder setColumnDelimiter(String delimiter);\n\n    /**\n     * Sets ID of Google Cloud project to be used when deidentifying data.\n     *\n     * @param projectId ID of Google Cloud project to be used when deidentifying data.\n     */\n    public abstract Builder setProjectId(String projectId);\n\n    abstract DLPReidentifyText autoBuild();\n\n    public DLPReidentifyText build() {\n      DLPReidentifyText dlpReidentifyText = autoBuild();\n      if (dlpReidentifyText.getReidentifyConfig() == null\n          && dlpReidentifyText.getReidentifyTemplateName() == null) {\n        throw new IllegalArgumentException(\n            \"Either reidentifyConfig or reidentifyTemplateName need to be set!\");\n      }\n      if (dlpReidentifyText.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 (dlpReidentifyText.getColumnDelimiter() == null\n          && dlpReidentifyText.getHeaderColumns() != null) {\n        throw new IllegalArgumentException(\n            \"Column delimiter should be set if headers are present.\");\n      }\n      if (dlpReidentifyText.getHeaderColumns() == null\n          && dlpReidentifyText.getColumnDelimiter() != null) {\n        throw new IllegalArgumentException(\n            \"Column headers should be supplied when delimiter is present.\");\n      }","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPReidentifyText.java#L150-L186","documentation":"DLPReidentifyText re-identifies previously de-identified text and needs to know how to perform the re-identification: either an inline ReidentifyConfig or the name of a stored re-identify template. Its builder's build() throws this IllegalArgumentException when both fields are null, since the DLP reidentify call would have no configuration.","triggerScenarios":"Calling DLPReidentifyText.newBuilder()...build() without calling either .setReidentifyTemplateName(String) or .setReidentifyConfig(ReidentifyConfig).","commonSituations":"Copying pipeline code from DLPDeidentifyText/DLPInspectText and forgetting to add the reidentify-specific configuration, or config-driven builds where both optional properties were missing.","solutions":["Call .setReidentifyTemplateName(\"projects/YOUR_PROJECT/locations/LOCATION/deidentifyTemplates/TEMPLATE_ID\") pointing at a stored re-identify template.","Or call .setReidentifyConfig(ReidentifyConfig.newBuilder()...build()) with an inline configuration.","If constructing from config, check that at least one of the two keys exists before building the transform."],"exampleFix":"// before\nDLPReidentifyText reidentify = DLPReidentifyText.newBuilder()\n    .setProjectId(\"my-project\")\n    .build(); // throws\n// after\nDLPReidentifyText reidentify = DLPReidentifyText.newBuilder()\n    .setProjectId(\"my-project\")\n    .setReidentifyTemplateName(\"projects/my-project/locations/global/deidentifyTemplates/my-template\")\n    .build();","handlingStrategy":"validation","validationCode":"if (reidentifyTemplateName == null && reidentifyConfig == null) {\n  throw new IllegalArgumentException(\"Provide either reidentifyTemplateName or reidentifyConfig before building DLPReidentifyText\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  DLPReidentifyText reidentify = DLPReidentifyText.newBuilder()...build();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"reidentifyConfig or reidentifyTemplateName\")) {\n    // supply a reidentify config/template and rebuild\n  }\n}","preventionTips":["Always configure exactly one of reidentifyTemplateName or reidentifyConfig in a shared builder helper.","Use a stored re-identify template referenced from central config.","Cover transform construction in unit tests so missing config fails before a pipeline run."],"tags":["java","apache-beam","google-cloud-dlp","builder-validation","illegal-argument-exception"],"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"}