Repository navigation
fix(proxy): hide model allowlist from client-facing model access denied errors #41310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
168b5bc
feat(proxy): configurable client-facing model access denied message
yassin-berriai d4d8cc9
fix(proxy): apply access denied message to JWT paths, sanitize denial…
yassin-berriai b99f0c8
fix(proxy): log configured model access denial only at the auth error…
yassin-berriai 7267c6b
Merge remote-tracking branch 'origin/main' into litellm_model_access_…
yassin-berriai f60a603
fix(proxy): log configured model access denials at the final response…
yassin-berriai b7af51c
Merge remote-tracking branch 'origin/main' into litellm_model_access_…
yassin-berriai 241b177
fix(proxy): log the internal model access denial reason for MCP sampl…
yassin-berriai 14d239f
test(proxy): pin JWT scope denial message shape through auth exceptio…
yassin-berriai 15f2e25
refactor(proxy): replace configurable model access denied message wit…
yassin-berriai b085a3c
fix(mcp): return fixed client message on sampling model access denial
yassin-berriai 5fee1c8
Merge remote-tracking branch 'origin/main' into litellm_model_access_…
yassin-berriai e48dde7
fix(tests): drop leftover merge markers in test_handle_jwt
yassin-berriai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from typing import Final | ||
|
|
||
| from fastapi import HTTPException | ||
|
|
||
| MODEL_ACCESS_DENIED_CLIENT_MESSAGE: Final = ( | ||
| "The requested model '{model}' is not available for this API key, or the model name is invalid. " | ||
| "Check the models available to you and try again." | ||
| ) | ||
|
|
||
|
|
||
| def model_access_denied_client_message(model: str | list[str]) -> str: | ||
| return MODEL_ACCESS_DENIED_CLIENT_MESSAGE.format(model=model) | ||
|
|
||
|
|
||
| class ModelAccessDeniedHTTPException(HTTPException): | ||
| def __init__(self, internal_message: str, status_code: int, detail: str | dict[str, str]) -> None: | ||
| super().__init__(status_code=status_code, detail=detail) | ||
| self.internal_message: Final = internal_message |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These model-access denials now always replace the established client-visible details with a fixed generic message. The repository requires backward-incompatible behavior changes to have a user-controlled flag, so an opt-in setting or another compatibility path must be provided before merging. The same unconditional change also affects the related user, team-member, and JWT denial paths.
Rule Used: What: avoid backwards-incompatible changes without user-controlled flags Why: This breaks current behaviour for users using existing functionality Example of BAD: this PR (#22164) introduced run_post_custom... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!