{"record":{"id":"de533f482fd2f03c","repo":"apache/beam","slug":"invalid-model-update-path-for-keys-is-empty","errorCode":null,"errorMessage":"Invalid model update, path for {keys} is empty","messagePattern":"Invalid model update, path for (.+?) is empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/base.py","lineNumber":975,"sourceCode":"    # Map cohort ids to a dictionary mapping new model paths to the keys that\n    # were originally in that cohort. We will use this to construct our new\n    # cohorts.\n    # cohort_path_mapping will be structured as follows:\n    # {\n    # original_cohort_id: {\n    #    'update/path/1': ['key1FromOriginalCohort', key2FromOriginalCohort'],\n    #    'update/path/2': ['key3FromOriginalCohort', key4FromOriginalCohort'],\n    #    }\n    # }\n    cohort_path_mapping: dict[KeyT, dict[str, list[KeyT]]] = {}\n    key_modelid_mapping: dict[KeyT, str] = {}\n    seen_keys = set()\n    for mp in model_paths:\n      keys = mp.keys\n      update_path = mp.update_path\n      model_id = mp.model_id\n      if len(update_path) == 0:\n        raise ValueError(f'Invalid model update, path for {keys} is empty')\n      for key in keys:\n        if key in seen_keys:\n          raise ValueError(\n              f'Invalid model update: {key} appears in multiple '\n              'update lists. A single model update must provide exactly one '\n              'updated path per key.')\n        seen_keys.add(key)\n        if key not in self._key_to_id_map:\n          raise ValueError(\n              f'Invalid model update: {key} appears in '\n              'update, but not in the original configuration.')\n        key_modelid_mapping[key] = model_id\n        cohort_id = self._key_to_id_map[key]\n        if cohort_id not in cohort_path_mapping:\n          cohort_path_mapping[cohort_id] = defaultdict(list)\n        cohort_path_mapping[cohort_id][update_path].append(key)\n    for key in self._key_to_id_map:\n      if key not in seen_keys:","sourceCodeStart":957,"sourceCodeEnd":993,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/base.py#L957-L993","documentation":"Raised by KeyedModelHandler.update_model_paths when an UpdateDawgModelPath (or similar update spec) has an empty update_path. Every model key submitted for a hot model update must carry a non-empty new model path so the handler can locate the updated model artifacts.","triggerScenarios":"Calling update_model_paths with a list of update objects where one has update_path set to '' (empty string), or constructing the update object without setting the path field.","commonSituations":"Building model update requests programmatically from config where a path key is missing or defaults to empty string; YAML/JSON update configs with a blank 'update_path' field; templating failures that silently drop the path value.","solutions":["Set a non-empty update_path for every update object passed to update_model_paths.","Validate the update list before calling: skip or fix entries with len(update_path) == 0.","Check the config/templating source to ensure the path field is populated, not an empty default."],"exampleFix":"// before\nupdate = UpdateModelPath(keys=['cohort-a'], update_path='', model_id='m2')\nhandler.update_model_paths([update])\n// after\nupdate = UpdateModelPath(keys=['cohort-a'], update_path='gs://bucket/model_v2', model_id='m2')\nhandler.update_model_paths([update])","handlingStrategy":"validation","validationCode":"bad = [u for u in updates if not u.update_path]\nif bad:\n    raise ValueError(f'update_path missing for keys: {[u.keys for u in bad]}')","typeGuard":"def has_update_path(u) -> bool:\n    return isinstance(u.update_path, str) and len(u.update_path) > 0","tryCatchPattern":null,"preventionTips":["Validate update objects at config-load time, before constructing update requests.","Avoid empty-string defaults for path fields in update configs."],"tags":["python","apache-beam","ml-inference","model-update"],"backgroundTag":"empty-required-field","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"}