apache/beam · error · ValueError
inspection_template_name or inspection_config must be…
Error message
inspection_template_name or inspection_config must be specified
What it means
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.
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
Example fix
// before
opts = CloudDLPOptions(project='p', deidentification_config=dcfg)
// after
opts = CloudDLPOptions(project='p', deidentification_config=dcfg,
inspection_config=dlp.InspectConfig(info_types=[...])) Defensive patterns
Strategy: validation
Validate before calling
if inspect_config is None and inspect_template is None:
raise ValueError('CloudDLPOptions needs inspection_template_name or inspection_config') Try / catch
try:
options = CloudDLPOptions(project=p, deidentification_config=c)
except ValueError as e:
if 'inspection_template_name or inspection_config' in str(e):
options = CloudDLPOptions(project=p, deidentification_config=c,
inspection_config=dlp.InspectConfig()) Prevention
- 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
When it happens
Trigger: Calling CloudDLPOptions(project=..., deidentification_template_name=...) with neither inspection_config nor inspection_template_name supplied.
Common situations: Only configuring deidentification and forgetting inspection; config loader dropping the inspection block; copying an example that used a template variable left unset.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Both deidentification_template_name and…
- deidentification_template_name or deidentification_config…
- Batch size is too large! It should be smaller or equal than
- Both a BigQuery table and a query were specified. Please…
- cache_root GCS bucket path is invalid.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/9371cd82bc5ce3e7.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/gcp/cloud_dlp.py:111
self.timeout = timeout
if deidentification_template_name is not None \
and deidentification_config is not None:
raise ValueError(
'Both deidentification_template_name and '
'deidentification_config were specified.'
' Please specify only one of these.')
elif deidentification_template_name is None \
and deidentification_config is None:
raise ValueError(
'deidentification_template_name or '
'deidentification_config must be specified.')
elif deidentification_template_name is not None:
self.config['deidentify_template_name'] = deidentification_template_name
else:
self.config['deidentify_config'] = deidentification_config
if inspection_config is None and inspection_template_name is None:
raise ValueError(
'inspection_template_name or inspection_config must be specified')
if inspection_template_name is not None:
self.config['inspect_template_name'] = inspection_template_name
if inspection_config is not None:
self.config['inspect_config'] = inspection_config
def expand(self, pcoll):
if self.project is None:
self.project = pcoll.pipeline.options.view_as(GoogleCloudOptions).project
if self.project is None:
raise ValueError(
'GCP project name needs to be specified in "project" pipeline option')
return (
pcoll
| ParDo(_DeidentifyFn(self.config, self.timeout, self.project)))
@typehints.with_input_types(str)View on GitHub (pinned to 12126d8942)