{"record":{"id":"404cdcaf4e7ec0ad","repo":"apache/beam","slug":"must-have-s-in-the-dict","errorCode":null,"errorMessage":"Must have %s in the dict.","messagePattern":"Must have (.+?) in the dict\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/healthcare/dicomio.py","lineNumber":490,"sourceCode":"            self.client,\n            self.credential))\n\n\nclass _StoreInstance(beam.DoFn):\n  \"\"\"A DoFn read or fetch dicom files then push it to a dicom store.\"\"\"\n  def __init__(\n      self,\n      destination_dict,\n      input_type,\n      buffer_size,\n      max_workers,\n      client,\n      credential=None):\n    # pre-check destination dict\n    required_keys = ['project_id', 'region', 'dataset_id', 'dicom_store_id']\n    for key in required_keys:\n      if key not in destination_dict:\n        raise ValueError('Must have %s in the dict.' % (key))\n    self.destination_dict = destination_dict\n    self.input_type = input_type\n    self.buffer_size = buffer_size\n    self.max_workers = max_workers\n    self.client = client\n    self.credential = credential\n\n  def start_bundle(self):\n    self.buffer = []\n\n  def finish_bundle(self):\n    for item in self._flush():\n      yield item\n\n  def process(\n      self,\n      element,\n      window=beam.DoFn.WindowParam,","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/healthcare/dicomio.py#L472-L508","documentation":"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.","triggerScenarios":"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).","commonSituations":"Building the dict from pipeline options where some flags were not set; renaming keys when refactoring; copying an example that used different key names.","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."],"exampleFix":"// before\ndestination_dict = {'project_id': 'p', 'dataset_id': 'd', 'dicom_store_id': 's'}\n// after\ndestination_dict = {'project_id': 'p', 'region': 'us-central1', 'dataset_id': 'd', 'dicom_store_id': 's'}","handlingStrategy":"validation","validationCode":"REQUIRED = ('project_id', 'region', 'dataset_id', 'dicom_store_id')\nmissing = [k for k in REQUIRED if k not in destination_dict]\nif missing:\n    raise ValueError(f'Missing destination keys: {missing}')","typeGuard":"def has_valid_destination(d):\n    return isinstance(d, dict) and all(k in d for k in ('project_id', 'region', 'dataset_id', 'dicom_store_id'))","tryCatchPattern":"try:\n    client = DicomClient(destination_dict)\nexcept ValueError as e:\n    if 'Must have' in str(e):\n        log.error('destination_dict incomplete: %s', e)\n    raise","preventionTips":["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"],"tags":["validation","missing-key","dicom","python","apache-beam"],"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"}