diff --git a/hermes_cli/config.py b/hermes_cli/config.py index 8419ba25f99f4..94f914d0cf986 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -4837,8 +4837,15 @@ def set_config_value(key: str, value: str, force: bool = False): try: with open(config_path, encoding="utf-8") as f: user_config = fast_safe_load(f) or {} - except Exception: - user_config = {} + except Exception as exc: + print( + f"✗ Cannot parse {config_path}: {exc}\n" + f" The file contains a YAML syntax error. Fix the error\n" + f" in your config file first, then retry.\n" + f" (hermes config edit will open it in your editor.)", + file=sys.stderr, + ) + sys.exit(1) # Handle nested keys (e.g., "tts.provider") including numeric list # indices (e.g., "custom_providers.0.api_key"). Delegates to @@ -5045,8 +5052,15 @@ def unset_config_value(key: str): try: with open(config_path, encoding="utf-8") as f: user_config = fast_safe_load(f) or {} - except Exception: - user_config = {} + except Exception as exc: + print( + f"✗ Cannot parse {config_path}: {exc}\n" + f" The file contains a YAML syntax error. Fix the error\n" + f" in your config file first, then retry.\n" + f" (hermes config edit will open it in your editor.)", + file=sys.stderr, + ) + sys.exit(1) removed = _unset_nested(user_config, key)