fix(cli): prevent crash in save_config_value when model is a string

load_cli_config() supports both string and dict formats for the model
key (e.g. `model: "anthropic/claude-opus-4"`), but save_config_value()
assumed all intermediate keys are dicts. When the config file used the
string format, running `/model <name>` would crash with TypeError:
'str' object does not support item assignment.

Add an isinstance check so non-dict values are replaced with a fresh
dict before descending.
This commit is contained in:
0xbyt4
2026-02-26 23:35:00 +03:00
parent bf9dd83c10
commit de197bd7cb

2
cli.py
View File

@@ -708,7 +708,7 @@ def save_config_value(key_path: str, value: any) -> bool:
keys = key_path.split('.')
current = config
for key in keys[:-1]:
if key not in current:
if key not in current or not isinstance(current[key], dict):
current[key] = {}
current = current[key]
current[keys[-1]] = value