{"record":{"id":"9371cd82bc5ce3e7","repo":"apache/beam","slug":"inspection-template-name-or-inspection-config-must-be","errorCode":null,"errorMessage":"inspection_template_name or inspection_config must be specified","messagePattern":"inspection_template_name or inspection_config must be specified","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/gcp/cloud_dlp.py","lineNumber":111,"sourceCode":"    self.timeout = timeout\n    if deidentification_template_name is not None \\\n        and deidentification_config is not None:\n      raise ValueError(\n          'Both deidentification_template_name and '\n          'deidentification_config were specified.'\n          ' Please specify only one of these.')\n    elif deidentification_template_name is None \\\n        and deidentification_config is None:\n      raise ValueError(\n          'deidentification_template_name or '\n          'deidentification_config must be specified.')\n    elif deidentification_template_name is not None:\n      self.config['deidentify_template_name'] = deidentification_template_name\n    else:\n      self.config['deidentify_config'] = deidentification_config\n\n    if inspection_config is None and inspection_template_name is None:\n      raise ValueError(\n          'inspection_template_name or inspection_config must be specified')\n    if inspection_template_name is not None:\n      self.config['inspect_template_name'] = inspection_template_name\n    if inspection_config is not None:\n      self.config['inspect_config'] = inspection_config\n\n  def expand(self, pcoll):\n    if self.project is None:\n      self.project = pcoll.pipeline.options.view_as(GoogleCloudOptions).project\n    if self.project is None:\n      raise ValueError(\n          'GCP project name needs to be specified in \"project\" pipeline option')\n    return (\n        pcoll\n        | ParDo(_DeidentifyFn(self.config, self.timeout, self.project)))\n\n\n@typehints.with_input_types(str)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/gcp/cloud_dlp.py#L93-L129","documentation":"CloudDLPRemovePII's constructor found neither an inspection_template_name nor an inspection_config, so it has no description of what sensitive info to detect. It is the empty-side of the template/config mutual-exclusion validation.","triggerScenarios":"Calling CloudDLPOptions(project=..., deidentification_template_name=...) with neither inspection_config nor inspection_template_name supplied.","commonSituations":"Only configuring deidentification and forgetting inspection; config loader dropping the inspection block; copying an example that used a template variable left unset.","solutions":["Provide inspection_template_name='projects/PROJECT/locations/LOCATION/inspectTemplates/TEMPLATE_ID' or an inline inspection_config=dlp.InspectConfig(...)","Verify the config file actually populates one of the two inspection options","Ensure string config values are not silently stripped to None"],"exampleFix":"// before\nopts = CloudDLPOptions(project='p', deidentification_config=dcfg)\n\n// after\nopts = CloudDLPOptions(project='p', deidentification_config=dcfg,\n    inspection_config=dlp.InspectConfig(info_types=[...]))","handlingStrategy":"validation","validationCode":"if inspect_config is None and inspect_template is None:\n    raise ValueError('CloudDLPOptions needs inspection_template_name or inspection_config')","typeGuard":null,"tryCatchPattern":"try:\n    options = CloudDLPOptions(project=p, deidentification_config=c)\nexcept ValueError as e:\n    if 'inspection_template_name or inspection_config' in str(e):\n        options = CloudDLPOptions(project=p, deidentification_config=c,\n            inspection_config=dlp.InspectConfig())","preventionTips":["Validate that both inspection and deidentification options exist before building the pipeline","Use a config schema check for required DLP keys","Keep template IDs in environment/config variables and assert they are set"],"tags":["python","apache-beam","gcp","dlp","configuration"],"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-20T03:17:13.778Z"}