{"record":{"id":"3765ce2ca0a4d3d1","repo":"apache/beam","slug":"invalid-model-update-key-appears-in-multiple-update-lists-a","errorCode":null,"errorMessage":"Invalid model update: {key} appears in multiple update lists. A single model update must provide exactly one updated path per key.","messagePattern":"Invalid model update: (.+?) appears in multiple update lists\\. A single model update must provide exactly one updated path per key\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/base.py","lineNumber":978,"sourceCode":"    # 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:\n        raise ValueError(\n            f'Invalid model update: {key} appears in the '\n            'original configuration, but not the update.')","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/base.py#L960-L996","documentation":"Raised by update_model_paths when the same key appears in more than one update entry. A single model update must provide exactly one new path per key; duplicate keys make the intended new path ambiguous.","triggerScenarios":"Passing two or more update objects to update_model_paths whose keys lists overlap (e.g. key 'k1' in two entries), or one entry whose keys list repeats a key already seen.","commonSituations":"Merging update specs from multiple sources without deduplicating keys; batching per-model updates where a model belongs to several cohorts; accidentally submitting the same update object twice in the list.","solutions":["Deduplicate keys across all update objects so each key appears exactly once.","Merge overlapping update entries into one entry with the single intended new path.","Validate before calling: collect all keys in a set and assert no duplicates."],"exampleFix":"// before\nhandler.update_model_paths([\n    UpdateModelPath(keys=['k1'], update_path='gs://b/m2'),\n    UpdateModelPath(keys=['k1', 'k2'], update_path='gs://b/m3')])\n// after\nhandler.update_model_paths([\n    UpdateModelPath(keys=['k1'], update_path='gs://b/m2'),\n    UpdateModelPath(keys=['k2'], update_path='gs://b/m3')])","handlingStrategy":"validation","validationCode":"all_keys = [k for u in updates for k in u.keys]\nif len(all_keys) != len(set(all_keys)):\n    dupes = {k for k in all_keys if all_keys.count(k) > 1}\n    raise ValueError(f'duplicate keys in update: {dupes}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate updates by key before calling update_model_paths.","Centralize update-spec construction in one function that enforces one-update-per-key."],"tags":["python","apache-beam","ml-inference","duplicate-key"],"backgroundTag":"conflicting-config-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}