fix(tools-config): widen stale-model picker guard to legacy image and video pickers
Same bug class as the plugin image picker crash (#77238): an unguarded `current_model = default_model` fallback that can index the catalog with a key it doesn't contain when the provider's default drifts from its catalog. Applies the `default if default in catalog else next(iter(catalog))` guard to _configure_imagegen_model and _configure_videogen_model_for_plugin.
This commit is contained in:
@@ -3997,7 +3997,10 @@ def _configure_imagegen_model(backend_name: str, config: dict) -> None:
|
||||
config[cfg_key] = cur_cfg
|
||||
current_model = cur_cfg.get("model") or default_model
|
||||
if current_model not in catalog:
|
||||
current_model = default_model
|
||||
# The saved model may belong to another provider (shared config key)
|
||||
# and the catalog default itself may have drifted — never index the
|
||||
# catalog with a key it doesn't contain.
|
||||
current_model = default_model if default_model in catalog else next(iter(catalog))
|
||||
|
||||
model_ids = list(catalog.keys())
|
||||
# Put current model at the top so the cursor lands on it by default.
|
||||
@@ -4228,7 +4231,9 @@ def _configure_videogen_model_for_plugin(plugin_name: str, config: dict) -> None
|
||||
config["video_gen"] = cur_cfg
|
||||
current_model = cur_cfg.get("model") or default_model
|
||||
if current_model not in catalog:
|
||||
current_model = default_model
|
||||
# Same guard as the image pickers: a stale cross-provider model or a
|
||||
# drifted default must not become an unindexable catalog key.
|
||||
current_model = default_model if default_model in catalog else next(iter(catalog))
|
||||
|
||||
model_ids = list(catalog.keys())
|
||||
ordered = [current_model] + [m for m in model_ids if m != current_model]
|
||||
|
||||
Reference in New Issue
Block a user