You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(router): handle moderation text lists during image routing - #48326
Moderation requests containing a list of texts now reach the provider instead of failing during routing. Existing image routing and supplied-message precedence stay unchanged
Details
TLDR
Problem this solves:
Moderation text lists return HTTP 500 before reaching providers
How it solves it:
Treat text-only lists as non-image input during routing
Keep supplied messages and structured image input handling unchanged
User Flow
Before, submitting multiple texts fails
Send POST https://litellm-domain/v1/moderations with {"model":"omni-moderation-next","input":["safe text","more safe text"]}
Receive HTTP 500 with 'str' object has no attribute 'get'
After, the same request returns moderation results
Send POST https://litellm-domain/v1/moderations with {"model":"omni-moderation-next","input":["safe text","more safe text"]}
Receive HTTP 200 with moderation results
Pre-Submission checklist
I have added meaningful tests
The handful of test files covering my change pass locally
My PR passes all required CI/CD checks
My PR's scope is as isolated as possible and solves one specific problem
Every automated review on my PR's latest commit has finished and findings are addressed
Verification
At 3458e4aa, strict text-list validation replaces the unchecked cast
CI unit, lint and Python checks pass
Local type-check and type-discipline gates pass against base
Local Ruff and formatting checks pass
Runtime probes accept empty and text-only batches and reject non-text lists
Earlier checks at 330f36c5
Both routing regressions and 14 adjacent image-routing tests pass
Removing the guard reproduces the original AttributeError
Both single/list moderation integration cases pass with scripted upstream
make check ran once, then its failed type gate passed after correction
Type
Bug Fix
Caveats
Low
Real-provider curl proof has not been captured
Local services were PostgreSQL 14 and Redis 8, not 16/7
Full make check was not rerun after the original targeted type correction
Latest local pytest collection is blocked by missing soundfile, CI unit tests pass
OSV findings also occur on base, all other checks passed
No automated review has reported on the latest head
Final Attestation
The tests check the relevant routing and moderation regressions
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
Comparing litellm_fix_moderation_list_input_20261025 (3458e4a) with main (72f1ac4)1
Footnotes
No successful run was found on main (dddbaa8) during the generation of this report, so 72f1ac4 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You have signed the CLA already but the status is still pending? Let us recheck it.
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
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.
Moderation requests containing a list of texts now reach the provider instead of failing during routing. Existing image routing and supplied-message precedence stay unchanged
Details
TLDR
Problem this solves:
How it solves it:
User Flow
Before, submitting multiple texts fails
https://litellm-domain/v1/moderationswith{"model":"omni-moderation-next","input":["safe text","more safe text"]}'str' object has no attribute 'get'After, the same request returns moderation results
https://litellm-domain/v1/moderationswith{"model":"omni-moderation-next","input":["safe text","more safe text"]}Pre-Submission checklist
Verification
At
3458e4aa, strict text-list validation replaces the unchecked castEarlier checks at
330f36c5make checkran once, then its failed type gate passed after correctionType
Bug Fix
Caveats
Low
make checkwas not rerun after the original targeted type correctionsoundfile, CI unit tests passFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/5eee69d5294c4e5fb1d4fad0aa549ef6
Open in Devin Desktop: https://app.devin.ai/desktop/session/5eee69d5294c4e5fb1d4fad0aa549ef6?variant=devin
Requested by: @yujonglee-berri