Skip to content

refactor(redaction): move the secret redactors out of the tracing crate - #53709

Merged
yujonglee-berri merged 1 commit into
litellm_cache_invalidation_warnings_reach_proxy_logfrom
litellm_redaction_crate
Nov 23, 2026
Merged

yujonglee-berri merged 1 commit into
litellm_cache_invalidation_warnings_reach_proxy_logfrom
litellm_redaction_crate

Conversation

@yujonglee-berri

@yujonglee-berri yujonglee-berri commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

[insert handwritten description here]

Details

TLDR

Problem this solves:

  • The secret redactors lived in litellm-tracing, the diagnostic logging crate
  • Spend logs and error mapping depended on that crate only to scrub text
  • core-utils re-exported them, so there were two import paths

How it solves it:

  • A new litellm-redaction crate holds SecretRedactor and TokenRedactor
  • Every user imports them from litellm_redaction
  • litellm-tracing keeps Processor and re-exports no redactor

Relevant 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

  • 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
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

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

E2E exception at 4324d9f.

Scope. Two files move from litellm/rust/crates/tracing/src to a new crate at litellm/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.rs becomes redaction/src/secret.rs and token_redaction.rs becomes redaction/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 new lib.rs only declares the two modules and exports SecretRedactor, TokenRedactor and REDACTED. Processor stays in litellm-tracing, because it processes log records, and now gets SecretRedactor from the new crate.

Every other edit is an import or a manifest line. callbacks-spend-log, callbacks-spend-logger and core-utils used litellm-tracing for nothing else, so they drop that dependency. auth-gcp, inference-messages and python-bridge still log through litellm-tracing and keep it next to the new one. core-utils/src/secret_redaction.rs was a one-line re-export with a single user inside core-utils, so it is deleted and that user imports from litellm_redaction. The Python classes in python-bridge keep 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-utils
(fmt and clippy print nothing and exit 0)

litellm-callbacks-spend-log   35 passed, and 2 passed in tests/goldens.rs
litellm-core-utils            297 passed
litellm-redaction             24 passed
litellm-tracing               3 passed, and 9 passed in tests/logging.rs

Before the move cargo test -p litellm-tracing ran 27 unit tests and 9 in tests/logging.rs. The same 27 run now, 24 in litellm-redaction and 3 in litellm-tracing. The spend log goldens run TokenRedactor through a second crate, and the core-utils tests run SecretRedactor through error mapping.

Type

🧹 Refactoring

Caveats (if any)

Low

  • The Python extension was not rebuilt and no Python test ran
    • python-bridge only changed one import, and clippy compiled it with all targets
  • litellm_core_utils::secret_redaction is gone
    • No crate in the workspace used that path

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

Devin Review

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.
@veria-ai

veria-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yujonglee-berri

Copy link
Copy Markdown
Contributor Author

@greptileai please review this PR. It is stacked, so compare it with its base branch and not with main.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Moves SecretRedactor, TokenRedactor, and REDACTED into litellm-redaction. Callers import them directly, while Processor stays in litellm-tracing.

Both moved implementations and their tests are byte-for-byte unchanged. No actionable issues were found against the stacked base.

yujonglee-berri explicitly notes that the internal secret_redaction re-export is removed and that Python tests were not run. The description reports Rust compilation and focused tests. This review did not rerun them.

  • Text scrubbers now live in their own Rust crate.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  T["litellm-tracing Processor"] --> R["litellm-redaction"]
  S["Spend log crates"] --> R
  C["core-utils"] --> R
  A["auth-gcp"] --> R
  P["Python bridge"] --> R
  I["inference-messages"] --> R
Loading

Reviews (1) · Last reviewed commit: "refactor(redaction): move the secret red..." · Reviewed by Greptile

@yujonglee-berri yujonglee-berri added the autoapprove This PR may be autoapproved by greptile. The author thinks that it does not need human review. label Nov 23, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving per the autoapprove label. Greptile scored the current head 5/5, but its auto-approval doesn't fire on stacked PRs whose base isn't main.

@yujonglee-berri
yujonglee-berri merged commit 4681fd9 into main Nov 23, 2026
71 of 72 checks passed
@yujonglee-berri
yujonglee-berri deleted the litellm_redaction_crate branch November 23, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoapprove This PR may be autoapproved by greptile. The author thinks that it does not need human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant