{"record":{"id":"2b712efeb593c2e6","repo":"apache/beam","slug":"either-inspecttemplatename-or-inspectconfig-must-be-supplied","errorCode":null,"errorMessage":"Either inspectTemplateName or inspectConfig must be supplied!","messagePattern":"Either inspectTemplateName or inspectConfig must be supplied!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPInspectText.java","lineNumber":141,"sourceCode":"     * Sets delimiter to be used when splitting values from input strings into columns.\n     *\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 list of column names if the input KV value is a delimited row.\n     *\n     * @param headerColumns List of column names if the input KV value is a delimited row.\n     */\n    public abstract Builder setHeaderColumns(PCollectionView<List<String>> headerColumns);\n\n    abstract DLPInspectText autoBuild();\n\n    public DLPInspectText build() {\n      DLPInspectText inspectText = autoBuild();\n      if (inspectText.getInspectTemplateName() == null && inspectText.getInspectConfig() == null) {\n        throw new IllegalArgumentException(\n            \"Either inspectTemplateName or inspectConfig must be supplied!\");\n      }\n      if (inspectText.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 (inspectText.getColumnDelimiter() == null && inspectText.getHeaderColumns() != null) {\n        throw new IllegalArgumentException(\n            \"Column delimiter should be set if headers are present.\");\n      }\n      if (inspectText.getHeaderColumns() == null && inspectText.getColumnDelimiter() != null) {\n        throw new IllegalArgumentException(\n            \"Column headers should be supplied when delimiter is present.\");\n      }\n      return inspectText;\n    }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPInspectText.java#L123-L159","documentation":"DLPInspectText's builder (Apache Beam Google Cloud DLP extension) requires at least one way to tell the DLP service what to inspect: either an inline InspectConfig or the name of a stored inspect template. The build() method throws this IllegalArgumentException when autoBuild() produced an instance with both fields null, because the subsequent DLP inspect call would be invalid.","triggerScenarios":"Calling DLPInspectText.newBuilder()...build() without calling either .setInspectTemplateName(String) or .setInspectConfig(InspectConfig) before building.","commonSituations":"Developers assume a default inspection config exists, copy a builder snippet and delete the template/config line, or build the transform programmatically from config where both optional keys were absent.","solutions":["Call .setInspectTemplateName(\"projects/YOUR_PROJECT/locations/LOCATION/inspectTemplates/TEMPLATE_ID\") with a template created in Cloud DLP.","Or call .setInspectConfig(InspectConfig.newBuilder()...build()) to supply an inline inspection configuration.","If building from application config, validate that at least one of the two config keys is present before constructing the builder."],"exampleFix":"// before\nDLPInspectText inspect = DLPInspectText.newBuilder()\n    .setProjectId(\"my-project\")\n    .build(); // throws\n// after\nDLPInspectText inspect = DLPInspectText.newBuilder()\n    .setProjectId(\"my-project\")\n    .setInspectTemplateName(\"projects/my-project/locations/global/inspectTemplates/my-template\")\n    .build();","handlingStrategy":"validation","validationCode":"if (inspectTemplateName == null && inspectConfig == null) {\n  throw new IllegalArgumentException(\"Provide either inspectTemplateName or inspectConfig before building DLPInspectText\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  DLPInspectText inspect = DLPInspectText.newBuilder()...build();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"inspectTemplateName or inspectConfig\")) {\n    // supply a default inspect config and retry the build\n  }\n}","preventionTips":["Always call exactly one of setInspectTemplateName or setInspectConfig in a shared builder helper.","Prefer a stored inspect template in central config so all pipelines have one.","Unit-test builder construction for each pipeline before deploy."],"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"}