From e3b099414da99d6b602c3d305ad29f5063ce4f83 Mon Sep 17 00:00:00 2001 From: mitnick Date: Sat, 27 Jun 2026 00:09:42 +0000 Subject: [PATCH] fix(config): surface tracing-stays-enabled consequence; isolate guard test The tracing-disable ImportError guard now logs that tracing may remain enabled and spans could leak to the provider, instead of a silent generic warning. The guard test stubs set_default_openai_api so it no longer reaches a real SDK call. Addresses Greptile review. --- strix/config/models.py | 12 +++++++++--- tests/test_model_config.py | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/strix/config/models.py b/strix/config/models.py index f308b542..c2860da8 100644 --- a/strix/config/models.py +++ b/strix/config/models.py @@ -71,9 +71,15 @@ def configure_sdk_model_defaults(settings: Settings) -> None: set_tracing_disabled(True) except ImportError as exc: # Disabling tracing eagerly initializes an httpx client that may need an - # optional transport (e.g. socksio for SOCKS proxies). Tracing is already - # being turned off, so a failure here is non-fatal — log and continue. - logger.warning("Could not disable SDK tracing: %s", exc) + # optional transport (e.g. socksio for SOCKS proxies). A failure here is + # non-fatal for startup, but tracing then stays at the SDK default + # (enabled), so make the consequence explicit rather than silent. + logger.warning( + "Could not disable SDK tracing (%s); tracing may remain enabled and " + "spans could be sent to the provider. Install the missing transport " + "(e.g. 'socksio') to resolve.", + exc, + ) _configure_litellm_compatibility() if llm.api_key: set_default_openai_key(llm.api_key, use_for_tracing=False) diff --git a/tests/test_model_config.py b/tests/test_model_config.py index 3d82437b..e5693f64 100644 --- a/tests/test_model_config.py +++ b/tests/test_model_config.py @@ -38,6 +38,9 @@ def test_configure_tolerates_tracing_import_error(monkeypatch: pytest.MonkeyPatc monkeypatch.setattr(models, "set_tracing_disabled", _raise) monkeypatch.setattr(models, "_configure_litellm_compatibility", lambda: None) + # With api_base=None the function reaches the real set_default_openai_api; + # stub it so the test stays isolated from SDK-side effects. + monkeypatch.setattr(models, "set_default_openai_api", lambda _mode: None) # Should not raise despite set_tracing_disabled blowing up. models.configure_sdk_model_defaults(_make_settings())