Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions litellm/proxy/auth/route_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
LiteLLMRoutes,
LitellmUserRoles,
UserAPIKeyAuth,
ProxyException
)

from .auth_checks_organization import _user_is_org_admin
Expand Down Expand Up @@ -92,9 +93,12 @@ def is_virtual_key_allowed_to_call_route(
):
return True

raise Exception(
f"Virtual key is not allowed to call this route. Only allowed to call routes: {valid_token.allowed_routes}. Tried to call route: {route}"
)
raise ProxyException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might fail a lot of our tests on ci/cd

Copy link
Contributor Author

@otaviofbrito otaviofbrito Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ishaan-jaff Would this be an expected behavior? The app returns a 500 Internal Server Error for unauthorized routes when using custom_auth.

Example usage:

    allowed_routes = list(LiteLLMRoutes.llm_api_routes.value + LiteLLMRoutes.info_routes.value)
    
    user_api_key_auth = UserAPIKeyAuth(
        api_key="dummy",
        key_alias="alias",
        rpm_limit_per_model=rpms,
        tpm_limit_per_model=tpms,
        models=[],
        allowed_routes=allowed_routes
    )

message=f"Virtual key is not allowed to call this route. Only allowed to call routes: {valid_token.allowed_routes}. Tried to call route: {route}",
type="auth_error",
param="api_key",
code=403,
)

@staticmethod
def _mask_user_id(user_id: str) -> str:
Expand Down
Loading