fix(rerank): log optional_rerank_params at debug to stop leaking request content - #32533
Conversation
…aking request content
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThis PR fixes a log-level issue in
Confidence Score: 5/5Safe to merge — the change is a single log-level demotion with no effect on request handling or response behavior. The only modified production line changes a log call from INFO to DEBUG; all request-handling logic is untouched. The new test mocks the HTTP transport (no real network calls), directly exercises the changed line, and would fail against the pre-fix code. No backwards-incompatible changes or auth-path modifications. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/rerank_api/main.py | Single-line change: verbose_logger.info → verbose_logger.debug for optional_rerank_params, matching the pattern already used by search/main.py and ocr/main.py |
| tests/test_litellm/rerank_api/test_main.py | New regression test using mocked HTTP transport (no real network calls); asserts marker content absent from INFO+ records and present at DEBUG, correctly targeting the "LiteLLM" logger name |
| tests/test_litellm/rerank_api/init.py | Empty init.py added to make the new test directory a Python package |
Reviews (1): Last reviewed commit: "fix(rerank): log optional_rerank_params ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…est content (BerriAI#32533) * fix(rerank): log optional_rerank_params at debug not info to avoid leaking request content * test(rerank): exercise sync rerank path so coverage counts the log line --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Relevant issues
Fixes #32525
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Live proxy at
LITELLM_LOG=INFOrouting to real AWS Bedrock (bedrock/amazon.rerank-v1:0), same curl in both runs:Before (line at
verbose_logger.info, the currentmainbehavior);grep optional_rerank_paramson the proxy log shows the raw request content at INFO:After (this PR, commit
24df024); same curl, same INFO log level,grep optional_rerank_paramsandgrep MARKER_on the proxy log return nothing:Both runs reached real AWS Bedrock (the account here lacks the
bedrock:RerankIAM action so the upstream call returns 403), which is fine because the leak happens atoptional_rerank_paramslogging before the provider call; the point is whether that content lands in logs at the default INFO levelType
🐛 Bug Fix
Changes
litellm/rerank_api/main.pylogged the mappedoptional_rerank_paramsat INFO. That dict always carries the caller'squeryanddocuments, so every rerank call wrote raw request content to stdout and any log sink at the defaultLITELLM_LOG=INFO. Because it is a plainverbose_loggercall outside the logging object, it also bypassesturn_off_message_loggingand theredact_messagesguards. This was the only completion/embedding/rerank path emitting request content at INFO; sibling code (search/main.py,ocr/main.py,litellm_core_utils/litellm_logging.py) already logsoptional_paramsat debugAdded a regression test at
tests/test_litellm/rerank_api/test_main.pythat driveslitellm.arerank(cohere provider, mocked transport) with marker query/documents and asserts no INFO-or-aboveLiteLLMlog record contains the request content, while theoptional_rerank_paramsline is still emitted at DEBUG. It fails on the pre-fixverbose_logger.infoand passes on the fixLink to Devin session: https://app.devin.ai/sessions/67a91a96b957427895a7f3aff032c5da