apache/beam · error · ValueError
Must have in the dict.
Error message
Must have %s in the dict.
What it means
dicomio's destination pre-check validates that destination_dict contains all four required keys: project_id, region, dataset_id, dicom_store_id. If any is missing, ValueError('Must have %s in the dict.') is raised, naming the first missing key. The client needs these to address the Healthcare DICOM store API endpoint.
Solutions
- Add all four required keys to destination_dict: project_id, region, dataset_id, dicom_store_id.
- Validate the dict before constructing the client (see validationCode).
- Check where destination_dict is built (e.g. pipeline options parsing) and fix missing values there.
Example fix
// before
destination_dict = {'project_id': 'p', 'dataset_id': 'd', 'dicom_store_id': 's'}
// after
destination_dict = {'project_id': 'p', 'region': 'us-central1', 'dataset_id': 'd', 'dicom_store_id': 's'} Defensive patterns
Strategy: validation
Validate before calling
REQUIRED = ('project_id', 'region', 'dataset_id', 'dicom_store_id')
missing = [k for k in REQUIRED if k not in destination_dict]
if missing:
raise ValueError(f'Missing destination keys: {missing}') Type guard
def has_valid_destination(d):
return isinstance(d, dict) and all(k in d for k in ('project_id', 'region', 'dataset_id', 'dicom_store_id')) Try / catch
try:
client = DicomClient(destination_dict)
except ValueError as e:
if 'Must have' in str(e):
log.error('destination_dict incomplete: %s', e)
raise Prevention
- Build destination_dict from a schema-checked pipeline options parser
- Validate all GCP destination config at pipeline start-up
- Keep key names consistent with the library's expected names; do not rename them
When it happens
Trigger: Constructing the dicomio client with a destination_dict lacking one or more of project_id, region, dataset_id, dicom_store_id (e.g. only passing a store path or partial config).
Common situations: Building the dict from pipeline options where some flags were not set; renaming keys when refactoring; copying an example that used different key names.
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
- input_type could only be 'bytes' or 'fileio'
- An unsupported sink was specified
- At least one of --render_port or --render_output must be…
- buffer_sec must be >= 0, got
- Cannot skip negative number of header lines
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/404cdcaf4e7ec0ad.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/io/gcp/healthcare/dicomio.py:490
self.client,
self.credential))
class _StoreInstance(beam.DoFn):
"""A DoFn read or fetch dicom files then push it to a dicom store."""
def __init__(
self,
destination_dict,
input_type,
buffer_size,
max_workers,
client,
credential=None):
# pre-check destination dict
required_keys = ['project_id', 'region', 'dataset_id', 'dicom_store_id']
for key in required_keys:
if key not in destination_dict:
raise ValueError('Must have %s in the dict.' % (key))
self.destination_dict = destination_dict
self.input_type = input_type
self.buffer_size = buffer_size
self.max_workers = max_workers
self.client = client
self.credential = credential
def start_bundle(self):
self.buffer = []
def finish_bundle(self):
for item in self._flush():
yield item
def process(
self,
element,
window=beam.DoFn.WindowParam,View on GitHub (pinned to 12126d8942)