From 708381948b0025f6f54e34b9e0e22b8d02070801 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Wed, 9 Sep 2026 18:34:07 -0700 Subject: [PATCH] fix(cli): compare the resolved settings path when deciding whether the lite up and autoroute backups guard it --- .../proxy/client/cli/commands/claude_settings.py | 2 +- .../proxy/client/cli/test_auth_commands.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/client/cli/commands/claude_settings.py b/litellm/proxy/client/cli/commands/claude_settings.py index 7e96d2a3a08..793728b0350 100644 --- a/litellm/proxy/client/cli/commands/claude_settings.py +++ b/litellm/proxy/client/cli/commands/claude_settings.py @@ -66,7 +66,7 @@ def claude_settings_path(environ: Mapping[str, str]) -> Path: def settings_file_owners(settings_path: Path) -> tuple[SettingsFileOwner, ...]: """The commands whose backups guard settings_path: `lite up` and `lite autoroute up` only ever manage the default file.""" - return SETTINGS_FILE_OWNERS if settings_path == CLAUDE_SETTINGS_PATH else () + return SETTINGS_FILE_OWNERS if settings_path.resolve() == CLAUDE_SETTINGS_PATH.resolve() else () def load_json_or_empty(path: Path) -> dict[str, JsonValue]: diff --git a/tests/test_litellm/proxy/client/cli/test_auth_commands.py b/tests/test_litellm/proxy/client/cli/test_auth_commands.py index 9c3c02a5e85..d3e6d8f66ef 100644 --- a/tests/test_litellm/proxy/client/cli/test_auth_commands.py +++ b/tests/test_litellm/proxy/client/cli/test_auth_commands.py @@ -1477,6 +1477,21 @@ class TestLoginConfigClaude: assert "Run `lite down` first" in result.output assert not default_settings_path.exists() + def test_flag_refuses_while_lite_up_holds_the_default_file_reached_through_a_symlinked_config_dir(self, tmp_path): + default_config_dir = tmp_path / "default-home" / ".claude" + default_config_dir.mkdir(parents=True) + alias = tmp_path / "claude-alias" + alias.symlink_to(default_config_dir, target_is_directory=True) + (tmp_path / "claude_settings_backup.json").write_text("{}") + + result, _settings_path, _backup_path = self._run_login( + tmp_path, ["--config-claude"], config_dir_env={"CLAUDE_CONFIG_DIR": str(alias)} + ) + + assert result.exit_code != 0 + assert "`lite up` is currently managing" in result.output + assert not (default_config_dir / "settings.json").exists() + def test_flag_writes_an_alternate_config_dir_even_while_lite_up_holds_the_default_file(self, tmp_path): (tmp_path / "claude_settings_backup.json").write_text("{}")