mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-30 01:52:18 +00:00
refactor(keys): freeze the service account route tuple and stamp metadata without seeding mutable literals
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
e68ea077f1
commit
b50265d75f
2 changed files with 6 additions and 7 deletions
|
|
@ -660,10 +660,10 @@ class LiteLLMRoutes(enum.Enum):
|
|||
KeyManagementRoutes.AUTO_ROUTER_MANAGE.value,
|
||||
]
|
||||
|
||||
team_service_account_key_routes = [
|
||||
team_service_account_key_routes = (
|
||||
KeyManagementRoutes.KEY_GENERATE.value,
|
||||
KeyManagementRoutes.KEY_UPDATE.value,
|
||||
]
|
||||
)
|
||||
|
||||
management_routes = (
|
||||
[
|
||||
|
|
|
|||
|
|
@ -2240,13 +2240,12 @@ async def generate_service_account_key_fn(
|
|||
)
|
||||
|
||||
if data.metadata is None or data.metadata.get("service_account_id") is None:
|
||||
service_account_id: Final = (
|
||||
(data.metadata or {}).get("service_account_id") or data.key_alias or str(uuid.uuid4())
|
||||
)
|
||||
data.metadata = { # rebind-ok: stamp the service_account_id onto the request so it persists on the key
|
||||
**(data.metadata or {}),
|
||||
service_account_id: Final = data.key_alias or str(uuid.uuid4())
|
||||
stamped_metadata: Final = { # mutable-ok: GenerateKeyRequest.metadata is a plain dict field
|
||||
**(data.metadata or MappingProxyType({})),
|
||||
"service_account_id": service_account_id,
|
||||
}
|
||||
data.metadata = stamped_metadata # rebind-ok: the request carries the stamp so it persists on the key
|
||||
|
||||
verbose_proxy_logger.debug("entered /key/generate")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue