BerriAI/litellm · error · KeyNotInCacheError
Key doesn't exist in cache + check_cache_only=True. key={has
Error message
Key doesn't exist in cache + check_cache_only=True. key={hashed_token}. What it means
Raised by _resolve_key when the caller demanded cache-only resolution (check_cache_only=True — typically under high load or DB outage) and the hashed token had no cache entry. It means the key was never seen (unknown/invalid token) or its cache entry expired and DB fallback is forbidden, so authentication fails without hitting the database; the hashed token is embedded for correlation.
Source
Thrown at litellm/proxy/auth/resolvers/store.py:111
Stopgap for the request flow that still consumes ``UserAPIKeyAuth`` for
budget, rate-limit, and policy state. Only Principals produced by
``resolve`` carry a source key.
"""
if principal.source_key is None:
raise PrincipalMissingSourceKeyError()
return principal.source_key
async def _resolve_key(self, hashed_token: str) -> UserAPIKeyAuth:
if self._prisma is None:
raise NoDatabaseConnectionError()
cached: Final = await self._cache.async_get_cache(key=hashed_token, model_type=UserAPIKeyAuth)
if cached is not None:
return _copy_user_api_key_auth_for_cache(user_api_key_obj=cached)
if self._check_cache_only:
raise KeyNotInCacheError(hashed_token)
from_db: Final[BaseModel | None] = await _fetch_key_object_from_db_with_reconnect(
hashed_token=hashed_token,
prisma_client=self._prisma,
parent_otel_span=self._parent_otel_span,
proxy_logging_obj=self._proxy_logging_obj,
)
if from_db is None:
raise KeyNotFoundError(hashed_token)
key: Final = UserAPIKeyAuth.model_validate(from_db.model_dump(exclude_none=True))
if key.object_permission_id and not key.object_permission:
try:
key.object_permission = await get_object_permission(
object_permission_id=key.object_permission_id,
prisma_client=self._prisma,
user_api_key_cache=self._cache,View on GitHub (pinned to 77b7c6c40c)
Solutions
- Disable check_cache_only so the resolver can fall back to the database.
- Warm the cache or reissue the key so it exists in cache.
Example fix
Retry the request without check_cache_only=True, or restart the proxy to refresh its cache.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/auth/resolvers/store.py:111 when the library encounters an invalid state.
Common situations: The key was looked up with check_cache_only=True and was not present in the cache.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/e64fa54d75e4b047.
Report an issue: GitHub.