Skip to content

test(params): fence proxy metadata keys out of provider bodies - #43368

Open
shrey-berri wants to merge 1 commit into
mainfrom
litellm_fence_proxy_metadata
Open

shrey-berri wants to merge 1 commit into
mainfrom
litellm_fence_proxy_metadata

Conversation

@shrey-berri

@shrey-berri shrey-berri commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

TLDR

The last two items of the internal-params depth item, after #43221 and #43222

Problem this solves:

  • The fence test never checked proxy keys inside metadata
  • The _litellm_* naming rule was not written down anywhere

How it solves it:

  • Fence test sends metadata={"user_api_key_hash": "h"} to all 6 providers
  • It asserts user_api_key_hash never appears in any request body
  • AGENTS.md now states the _litellm_* rule and bans internal state in metadata

Linear ticket

Resolves LIT-8316

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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 more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays 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

Test and docs only, so nothing a user sees changes. The check that matters is whether the new assertion catches a real leak. Turning on litellm.enable_preview_features makes LiteLLM forward metadata to OpenAI, which leaks user_api_key_hash into the request body

Setup Old fence test New fence test
Default settings 24 passed 24 passed
litellm.enable_preview_features = True 24 passed, leak not caught 4 OpenAI cases fail on 'user_api_key_hash' not in keys

Type

✅ Test
📖 Documentation

Caveats (if any)

Medium

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Generated by Claude Code

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
shrey-berri requested a review from a team September 26, 2026 23:20
@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Documents internal parameter naming and adds test coverage.

The PR appears safe to merge.

Summary

This PR documents the internal-kwarg naming convention and extends the provider wire test to check that user_api_key_hash inside request metadata does not appear in provider bodies.

  • The assertion covers the existing six-provider, sync/async, and streaming/non-streaming matrix.
  • No production behavior changes.

Reviews (1) · Last reviewed commit: "test(params): fence proxy metadata keys ..."

@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant