From 34942dc71fab83ab01df8ebf003c9fd157af38ea Mon Sep 17 00:00:00 2001 From: Chris Nestrud Date: Tue, 6 Jan 2026 16:20:12 -0600 Subject: [PATCH] feat: drop /accounts/{account_id} from model URL if env var missing Co-authored-by: cecli (synthetic/hf:zai-org/GLM-4.7) --- cecli/helpers/model_providers.py | 7 ++++--- tests/basic/test_model_provider_manager.py | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cecli/helpers/model_providers.py b/cecli/helpers/model_providers.py index 99770fc5c7f..19fcbd33167 100644 --- a/cecli/helpers/model_providers.py +++ b/cecli/helpers/model_providers.py @@ -518,9 +518,10 @@ def _fetch_provider_models(self, provider: str) -> Optional[Dict]: if "{account_id}" in models_url: account_id = self._get_account_id(provider) if not account_id: - print(f"Failed to fetch {provider} model list: account_id_env not set") - return None - models_url = models_url.replace("{account_id}", account_id) + # Remove /accounts/{account_id} portion from URL if account_id is not set + models_url = models_url.replace("/accounts/{account_id}", "") + else: + models_url = models_url.replace("{account_id}", account_id) headers = {} default_headers = config.get("default_headers") or {} headers.update(default_headers) diff --git a/tests/basic/test_model_provider_manager.py b/tests/basic/test_model_provider_manager.py index 520713ce849..fb9ddd46721 100644 --- a/tests/basic/test_model_provider_manager.py +++ b/tests/basic/test_model_provider_manager.py @@ -505,7 +505,7 @@ def _fake_get(url, *, headers=None, timeout=None, verify=None): assert captured["url"] == "https://api.fireworks.ai/v1/accounts/my-account-id/models" -def test_models_url_account_id_missing_skips_fetch(monkeypatch, tmp_path, capsys): +def test_models_url_account_id_missing_removes_account_path(monkeypatch, tmp_path): config = { "fireworks_ai": { "api_base": "https://api.fireworks.ai/inference/v1", @@ -519,10 +519,23 @@ def test_models_url_account_id_missing_skips_fetch(monkeypatch, tmp_path, capsys manager = _make_manager(tmp_path, config) monkeypatch.delenv("FIREWORKS_AI_ACCOUNT_ID", raising=False) - assert manager._fetch_provider_models("fireworks_ai") is None + captured = {} + + def _fake_get(url, *, headers=None, timeout=None, verify=None): + captured["url"] = url + captured["headers"] = headers + captured["timeout"] = timeout + captured["verify"] = verify + return DummyResponse({"data": []}) + + monkeypatch.setattr("requests.get", _fake_get) + + result = manager._fetch_provider_models("fireworks_ai") - captured = capsys.readouterr() - assert "account_id_env not set" in captured.out + # Should return the payload, not None + assert result == {"data": []} + # URL should have /accounts/{account_id} removed + assert captured["url"] == "https://api.fireworks.ai/v1/models" def test_models_url_without_placeholder_unchanged(monkeypatch, tmp_path):