Repository navigation
refactor(redaction): move the secret redactors out of the tracing crate - #53709
Conversation
SecretRedactor and TokenRedactor scrub secrets from free text. Spend logs, error mapping and the GCP auth failures use them as well as log records, so they move to a new litellm-redaction crate that every user imports directly. litellm-tracing keeps Processor and no longer re-exports the redactors.
PR overviewNo security issues were found in this pull request. Reviews
|
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@greptileai please review this PR. It is stacked, so compare it with its base branch and not with main. |
[Medium impact] The PR appears safe to merge.
|
Handwritten 1-3 sentence description
[insert handwritten description here]
Details
TLDR
Problem this solves:
litellm-tracing, the diagnostic logging cratecore-utilsre-exported them, so there were two import pathsHow it solves it:
litellm-redactioncrate holdsSecretRedactorandTokenRedactorlitellm_redactionlitellm-tracingkeepsProcessorand re-exports no redactorRelevant issues
Top of the stack over #53690 and #53539
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
E2E exception at 4324d9f.
Scope. Two files move from
litellm/rust/crates/tracing/srcto a new crate atlitellm/rust/crates/redaction, and their users switch imports. Nothing a caller or an operator can observe changes. No test was added, removed or rewritten.Rationale. The change is mechanical.
redaction.rsbecomesredaction/src/secret.rsandtoken_redaction.rsbecomesredaction/src/token.rs, and git reports both renames at 100% similarity, so the code and its inline tests are byte for byte the same. The newlib.rsonly declares the two modules and exportsSecretRedactor,TokenRedactorandREDACTED.Processorstays inlitellm-tracing, because it processes log records, and now getsSecretRedactorfrom the new crate.Every other edit is an import or a manifest line.
callbacks-spend-log,callbacks-spend-loggerandcore-utilsusedlitellm-tracingfor nothing else, so they drop that dependency.auth-gcp,inference-messagesandpython-bridgestill log throughlitellm-tracingand keep it next to the new one.core-utils/src/secret_redaction.rswas a one-line re-export with a single user insidecore-utils, so it is deleted and that user imports fromlitellm_redaction. The Python classes inpython-bridgekeep their names and bodies.Commands and results, from
litellm/rust.cargo fmt -p litellm-redaction -p litellm-tracing -p litellm-core-utils -p litellm-auth-gcp -p litellm-callbacks-spend-log \ -p litellm-callbacks-spend-logger -p litellm-inference-messages -p litellm-python-bridge -- --check cargo clippy --locked -q -p litellm-redaction -p litellm-tracing -p litellm-core-utils -p litellm-auth-gcp \ -p litellm-callbacks-spend-log -p litellm-callbacks-spend-logger -p litellm-inference-messages -p litellm-python-bridge \ --all-targets -- -D warnings cargo test --locked -q -p litellm-redaction -p litellm-tracing -p litellm-callbacks-spend-log -p litellm-core-utilsBefore the move
cargo test -p litellm-tracingran 27 unit tests and 9 intests/logging.rs. The same 27 run now, 24 inlitellm-redactionand 3 inlitellm-tracing. The spend log goldens runTokenRedactorthrough a second crate, and thecore-utilstests runSecretRedactorthrough error mapping.Type
🧹 Refactoring
Caveats (if any)
Low
python-bridgeonly changed one import, and clippy compiled it with all targetslitellm_core_utils::secret_redactionis goneFinal Attestation