{"record":{"id":"0bef9af8198f4374","repo":"apache/beam","slug":"deidentification-template-name-or-deidentification-config","errorCode":null,"errorMessage":"deidentification_template_name or deidentification_config must be specified.","messagePattern":"deidentification_template_name or deidentification_config must be specified\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/gcp/cloud_dlp.py","lineNumber":102,"sourceCode":"        Configuration for the inspector used to detect sensitive data in text.\n        If both template name and config are supplied,\n        config takes precedence.\n      timeout (float): Optional. The amount of time, in seconds, to wait for\n        the request to complete.\n\n    \"\"\"\n    self.config = {}\n    self.project = project\n    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","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/gcp/cloud_dlp.py#L84-L120","documentation":"CloudDLPOptions requires deidentification information: at least one of deidentification_template_name or deidentification_config must be given. Supplying neither means the DLP deidentify call has no way to know how to transform the data, so __init__ raises ValueError.","triggerScenarios":"Calling CloudDLPOptions(project=..., inspection_config=...) without either deidentification argument (both None).","commonSituations":"Omitting deidentification options assuming inspection-only usage is allowed; config-file loaders dropping empty/None values so both end up None; docs examples trimmed to remove the deidentify arguments.","solutions":["Add deidentification_template_name='projects/PROJECT/locations/LOCATION/deidentifyTemplates/TEMPLATE_ID' or an inline deidentification_config=dlp.DeidentifyConfig(...)","If no deidentification is desired, confirm whether your Beam version supports inspection-only options; otherwise supply a minimal DeidentifyConfig","Check config loading so empty strings are not converted to None unexpectedly"],"exampleFix":"// before\nopts = CloudDLPOptions(project='p', inspection_config=cfg)\n\n// after\nopts = CloudDLPOptions(project='p', inspection_config=cfg,\n    deidentification_template_name='projects/p/deidentifyTemplates/t')","handlingStrategy":"validation","validationCode":"if deid_template is None and deid_config is None:\n    raise ValueError('CloudDLPOptions needs deidentification_template_name or deidentification_config')","typeGuard":null,"tryCatchPattern":"try:\n    options = CloudDLPOptions(project=p, inspection_config=i)\nexcept ValueError as e:\n    if 'must be specified' in str(e):\n        options = CloudDLPOptions(project=p, inspection_config=i,\n            deidentification_config=dlp.DeidentifyConfig())","preventionTips":["Always configure deidentification when using CloudDLP transforms","Check config-file parsing doesn't drop required deidentify fields","Copy complete examples from the Beam docs, not partial snippets"],"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"}