mirror of
https://github.com/usestrix/strix.git
synced 2026-10-11 03:37:54 +00:00
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.
This commit is contained in:
parent
286c6c3eef
commit
e3b099414d
2 changed files with 12 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue