{"record":{"id":"7528ea3b1a057489","repo":"apache/beam","slug":"invalid-model-update-key-appears-in-the-original","errorCode":null,"errorMessage":"Invalid model update: {key} appears in the original configuration, but not the update.","messagePattern":"Invalid model update: (.+?) appears in the original configuration, but not the update\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/base.py","lineNumber":994,"sourceCode":"      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.')\n\n    # We now have our new set of cohorts. For each one, update our local model\n    # handler configuration and send the results to the ModelManager\n    for old_cohort_id, path_key_mapping in cohort_path_mapping.items():\n      for updated_path, keys in path_key_mapping.items():\n        cohort_id = old_cohort_id\n        if old_cohort_id not in keys:\n          # Create new cohort\n          cohort_id = keys[0]\n          for key in keys:\n            self._key_to_id_map[key] = cohort_id\n          mh = self._id_to_mh_map[old_cohort_id]\n          self._id_to_mh_map[cohort_id] = deepcopy(mh)\n        self._id_to_mh_map[cohort_id].update_model_path(updated_path)\n        model.update_model_handler(cohort_id, updated_path, old_cohort_id)\n        model_id = key_modelid_mapping[cohort_id]","sourceCodeStart":976,"sourceCodeEnd":1012,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/base.py#L976-L1012","documentation":"Raised by update_model_paths when a key present in the handler's original configuration is missing from the update. Every originally configured key must receive exactly one updated path, so the update must be complete.","triggerScenarios":"Calling update_model_paths with updates covering only a subset of the keys used at handler construction (e.g. updating k1 but omitting k2 which was in the original config).","commonSituations":"Assuming updates are partial/partially-applicable; generating the update list from a filtered config; a cohort's update entry was dropped by an earlier validation or merge step.","solutions":["Provide an update entry for every key in the original configuration.","Enumerate the handler's configured keys and assert the update covers all of them before calling.","If only some models changed, still supply their existing paths as the updated paths for unchanged keys."],"exampleFix":"// before\nhandler.update_model_paths([UpdateModelPath(keys=['k1'], update_path='gs://b/m2', model_id='m2')])  # k2 missing\n// after\nhandler.update_model_paths([\n    UpdateModelPath(keys=['k1'], update_path='gs://b/m2', model_id='m2'),\n    UpdateModelPath(keys=['k2'], update_path='gs://b/m1', model_id='m1')])","handlingStrategy":"validation","validationCode":"missing = set(handler._key_to_id_map) - {k for u in updates for k in u.keys}\nif missing:\n    raise ValueError(f'keys missing from update: {missing}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat updates as full replacements: always cover every configured key.","Generate update lists by iterating the handler's key set, not a filtered subset."],"tags":["python","apache-beam","ml-inference","incomplete-update"],"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"}