Repository navigation
test(params): fence proxy metadata keys out of provider bodies - #43368
Open
shrey-berri wants to merge 1 commit into
Open
shrey-berri wants to merge 1 commit into
shrey-berri wants to merge 1 commit into
Conversation
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The fence test now sends metadata={"user_api_key_hash": "h"} and asserts the key reaches none of the six providers. AGENTS.md now states the _litellm_* naming rule for internal kwargs and that internal state never goes into metadata
shrey-berri
force-pushed
the
litellm_fence_proxy_metadata
branch
from
October 23, 2026 22:17
f3cf654 to
91c3bf4
Compare
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds one more check to the test that makes sure LiteLLM's internal settings never end up in the request we send to a provider. The test now also passes the kind of key the proxy puts in metadata and fails if that key reaches any of the six providers we cover. It also writes down the naming rule for internal settings so new code keeps them out of provider requests by default
Details
TLDR
The last two items of the internal-params depth item, after #43221 and #43222
Problem this solves:
metadata_litellm_*naming rule was not written down anywhereHow it solves it:
metadata={"user_api_key_hash": "h"}to all 6 providersuser_api_key_hashnever appears in any request body_litellm_*rule and bans internal state inmetadataLinear ticket
Resolves LIT-8316
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
This PR only touches a test and AGENTS.md, so nothing a user sees changes and there is no live proxy run to show. The thing worth proving is that the new line catches a real leak, so each side runs the test twice. The first run uses default settings, which is all CI ever runs and passes on both sides. The second run deliberately breaks LiteLLM by turning on
litellm.enable_preview_features, which makes it copymetadatainto the OpenAI request body. A useful assertion has to go red thereBoth runs use
PYTHONPATH=tests:.from the repo rootBefore (f3d53a9)
Default settings
pytest tests/integration/providers/test_internal_params_wire.py -qMetadata forwarding turned on by hand
python -c "import litellm, pytest, sys; litellm.enable_preview_features = True; sys.exit(pytest.main(['tests/integration/providers/test_internal_params_wire.py', '-q']))"The old test stays green even though OpenAI now receives
user_api_key_hashAfter (91c3bf4)
Default settings
pytest tests/integration/providers/test_internal_params_wire.py -qMetadata forwarding turned on by hand
python -c "import litellm, pytest, sys; litellm.enable_preview_features = True; sys.exit(pytest.main(['tests/integration/providers/test_internal_params_wire.py', '-q']))"The new assertion catches the broken build on every OpenAI case
Type
✅ Test
📖 Documentation
Final Attestation