mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(mcp): set LITELLM_MASTER_KEY env var in e2e tests to prevent lifespan reset
The FastAPI lifespan event (proxy_startup_event) re-reads master_key from the LITELLM_MASTER_KEY env var, overriding whatever initialize() set from the YAML config. Without this env var, master_key becomes None, causing all users to be treated as INTERNAL_USER with no MCP server access — resulting in "User not allowed to call this tool" errors. Closes #22330 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
df99be904c
commit
456ad503d1
1 changed files with 4 additions and 0 deletions
|
|
@ -35,6 +35,10 @@ def _clear_proxy_database_env() -> typing.Iterator[None]:
|
|||
"""Ensure local proxy DB settings don't leak into tests."""
|
||||
mp = pytest.MonkeyPatch()
|
||||
mp.delenv("DATABASE_URL", raising=False)
|
||||
# The FastAPI lifespan event (proxy_startup_event) re-reads master_key from
|
||||
# the LITELLM_MASTER_KEY env var, overriding whatever initialize() set from
|
||||
# the config file. We must set it here so the lifespan doesn't reset it to None.
|
||||
mp.setenv("LITELLM_MASTER_KEY", "sk-1234")
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue