{"record":{"id":"a52ef57265acf937","repo":"apache/beam","slug":"both-deidentification-template-name-and-deidentification","errorCode":null,"errorMessage":"Both deidentification_template_name and deidentification_config were specified. Please specify only one of these.","messagePattern":"Both deidentification_template_name and deidentification_config were specified\\. Please specify only one of these\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/gcp/cloud_dlp.py","lineNumber":96,"sourceCode":"        config is more important.\n      inspection_template_name (str): This or `inspection_config` required.\n        Name of inspection template to be used\n        to detect sensitive data in text.\n      inspection_config\n        (``Union[dict, google.cloud.dlp_v2.types.InspectConfig]``):\n        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","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/gcp/cloud_dlp.py#L78-L114","documentation":"CloudDLPOptions (cloud_dlp.py __init__) validates deidentification arguments as mutually exclusive: providing BOTH deidentification_template_name and deidentification_config is rejected because DLP should use either a stored template or an inline config, not both.","triggerScenarios":"Calling CloudDLPOptions(..., deidentification_template_name='projects/p/deidentifyTemplates/t', deidentification_config=DeidentifyConfig(...)) — both non-None.","commonSituations":"Merging config from two sources (defaults provide a template, user code adds an inline config); copy-paste adding both parameters; migrating from template to config while keeping the old argument.","solutions":["Pass only deidentification_template_name OR only deidentification_config","If both sources set values, drop one before constructing CloudDLPOptions","If a stored template should win, explicitly set the config argument to None"],"exampleFix":"// before\nopts = CloudDLPOptions(project='p', inspection_config=cfg,\n    deidentification_template_name=tmpl, deidentification_config=dcfg)\n\n// after\nopts = CloudDLPOptions(project='p', inspection_config=cfg,\n    deidentification_template_name=tmpl)","handlingStrategy":"validation","validationCode":"assert not (deid_template is not None and deid_config is not None), \\\n    'use either deidentification_template_name or deidentification_config, not both'","typeGuard":null,"tryCatchPattern":"try:\n    options = CloudDLPOptions(project=p, deidentification_template_name=t, deidentification_config=c, inspection_config=i)\nexcept ValueError as e:\n    if 'only one of these' in str(e):\n        options = CloudDLPOptions(project=p, deidentification_template_name=t, inspection_config=i)","preventionTips":["Treat template vs inline config as an explicit either-or choice in your config schema","Merge defaults and user config with precedence, never concatenation","Document which deidentification mechanism your pipeline uses"],"tags":["python","apache-beam","gcp","dlp","configuration"],"backgroundTag":"mutually-exclusive-options","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"}