Skip to content

fix(router): handle moderation text lists during image routing - #48326

Closed
yujonglee-berri wants to merge 3 commits into
mainfrom
litellm_fix_moderation_list_input_20261025
Closed

yujonglee-berri wants to merge 3 commits into
mainfrom
litellm_fix_moderation_list_input_20261025

Conversation

@yujonglee-berri

@yujonglee-berri yujonglee-berri commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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

  1. Send POST https://litellm-domain/v1/moderations with {"model":"omni-moderation-next","input":["safe text","more safe text"]}
  2. Receive HTTP 500 with 'str' object has no attribute 'get'

After, the same request returns moderation results

  1. Send POST https://litellm-domain/v1/moderations with {"model":"omni-moderation-next","input":["safe text","more safe text"]}
  2. 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

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


Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@codspeed

codspeed Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

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.

Learn more about system calls

See affected benchmarks

✅ 35 untouched benchmarks


Comparing litellm_fix_moderation_list_input_20261025 (3458e4a) with main (72f1ac4)1

Open in CodSpeed

Footnotes

  1. 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. ↩

@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
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.

@yujonglee-berri
yujonglee-berri marked this pull request as draft November 8, 2026 23:59
@mateo-berri

Copy link
Copy Markdown
Contributor

Main routes text-list moderation inputs to the text deployment through #49371. Reopen #48326 if moderation still fails or something is missing

@mateo-berri mateo-berri closed this Nov 9, 2026
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.

3 participants