{"record":{"id":"e23b356939c249de","repo":"apache/beam","slug":"invalid-model-update-key-appears-in-update-but-not-in-the","errorCode":null,"errorMessage":"Invalid model update: {key} appears in update, but not in the original configuration.","messagePattern":"Invalid model update: (.+?) appears in update, but not in the original configuration\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/base.py","lineNumber":984,"sourceCode":"    # }\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.')\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","sourceCodeStart":966,"sourceCodeEnd":1002,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/base.py#L966-L1002","documentation":"Raised by update_model_paths when an update references a key that was never part of the KeyedModelHandler's original per-key configuration. Updates can only replace paths for keys the handler already knows via its _key_to_id_map.","triggerScenarios":"Calling update_model_paths with an update whose keys include a key absent from the mapping used at handler construction (e.g. new cohort key 'k9' not in the original update_model_path setup).","commonSituations":"Adding a new model cohort via an update instead of rebuilding the handler; renamed/typo'd keys between initial setup and update; stale update specs generated from a different handler configuration.","solutions":["Include only keys that exist in the handler's original configuration.","Fix key typos/mismatches between the initial setup and the update spec.","To add new cohorts, re-create the KeyedModelHandler with the full key set instead of using update_model_paths."],"exampleFix":"// before\nhandler.update_model_paths([UpdateModelPath(keys=['k_new'], update_path='gs://b/m2', model_id='m2')])  # k_new never configured\n// after\nhandler.update_model_paths([UpdateModelPath(keys=['k1'], update_path='gs://b/m2', model_id='m2')])  # k1 was in original config","handlingStrategy":"validation","validationCode":"known = set(handler._key_to_id_map)\nunknown = {k for u in updates for k in u.keys} - known\nif unknown:\n    raise ValueError(f'keys not in original config: {unknown}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source update keys from the same configuration used to build the handler.","Re-create the handler when adding new cohorts instead of updating unknown keys."],"tags":["python","apache-beam","ml-inference","unknown-key"],"backgroundTag":"record-not-found","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"}