apache/beam · error · ValueError
Invalid model update
Error message
Invalid model update: {key} appears in update, but not in the original configuration. What it means
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.
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.
Example fix
// before handler.update_model_paths([UpdateModelPath(keys=['k_new'], update_path='gs://b/m2', model_id='m2')]) # k_new never configured // after handler.update_model_paths([UpdateModelPath(keys=['k1'], update_path='gs://b/m2', model_id='m2')]) # k1 was in original config
Defensive patterns
Strategy: validation
Validate before calling
known = set(handler._key_to_id_map)
unknown = {k for u in updates for k in u.keys} - known
if unknown:
raise ValueError(f'keys not in original config: {unknown}') Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Cannot make make an unkeyed model handler with pre or…
- Cannot override RemoteModelHandler.load_model, implement…
- Cannot override RemoteModelHandler.run_inference, implement…
- Cannot use an unkeyed model handler with pre or…
- Empty list maps to model handler
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/e23b356939c249de.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/inference/base.py:984
# }
cohort_path_mapping: dict[KeyT, dict[str, list[KeyT]]] = {}
key_modelid_mapping: dict[KeyT, str] = {}
seen_keys = set()
for mp in model_paths:
keys = mp.keys
update_path = mp.update_path
model_id = mp.model_id
if len(update_path) == 0:
raise ValueError(f'Invalid model update, path for {keys} is empty')
for key in keys:
if key in seen_keys:
raise ValueError(
f'Invalid model update: {key} appears in multiple '
'update lists. A single model update must provide exactly one '
'updated path per key.')
seen_keys.add(key)
if key not in self._key_to_id_map:
raise ValueError(
f'Invalid model update: {key} appears in '
'update, but not in the original configuration.')
key_modelid_mapping[key] = model_id
cohort_id = self._key_to_id_map[key]
if cohort_id not in cohort_path_mapping:
cohort_path_mapping[cohort_id] = defaultdict(list)
cohort_path_mapping[cohort_id][update_path].append(key)
for key in self._key_to_id_map:
if key not in seen_keys:
raise ValueError(
f'Invalid model update: {key} appears in the '
'original configuration, but not the update.')
# We now have our new set of cohorts. For each one, update our local model
# handler configuration and send the results to the ModelManager
for old_cohort_id, path_key_mapping in cohort_path_mapping.items():
for updated_path, keys in path_key_mapping.items():
cohort_id = old_cohort_idView on GitHub (pinned to 12126d8942)