Repository navigation
[Fix] multimodal: Fail bad client media with a client error - #48778
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
…ader; map snapshot errors to client errors
# Conflicts: # python/sglang/srt/arg_groups/field_order.py
|
/rerun-test test_media_input_errors.py test_media_url_security.py test_base_processor_bad_input.py test_media_artifact_processor.py test_inkling_media_errors.py test_audio_container_decode.py test_preprocess_cache.py registered/unit/models/test_kimi_k25.py test_server_args_migration.py registered/unit/server_args/test_server_args.py |
|
/rerun-test test_feature_identity.py |
|
🚀 🚀 |
|
🚀 |
|
/rerun-test registered/unit/multimodal/rust/shared/test_fetch.py |
|
🚀 |
Carry media_url_timeout and allow_local_media_files (#48778) through MultimodalProcessorConfig.
…lvers sgl-project#48778 dropped the is_file check in _read_media_bytes, so registered-scheme URLs with an image extension skipped the resolver registry. sgl-project#51926 added the Inkling-2 processor, whose _resolve_image did not consult the registry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Port of #48414
Takes the media-input hardening from the Kimi-K3.1 Day-0 branch and finishes it for every loader: bad client media fails the request as a client error (400), and server-side invariant failures are no longer reported as one. The HEIF opener and the new image extensions from the same branch are in #49673.
Summary
On main, these reach the server as a 500 or hang a worker:
/dev/zerogrows memory without bound (8.5 GB in 4 s for an image); a directory or missing path is a 500./9j/) is opened as a file path and fails with a 500._load_single_itempath,snapshot_mediaanddecode_media_snapshot, an unreachable URL, a timeout or a decompression bomb is a 500, because those paths skip the client-error mapping the base processor does.With this PR:
read_local_media_file/check_local_media_fileinmultimodal/media_io.py) for images, video and audio, and for the loaders that read paths themselves (Inkling, MiMo, MoSS-VL). It opens withO_NONBLOCK(a FIFO fails at once), accepts only regular files, caps the size at--media-url-max-file-size-mb, and turns a missing, directory, looping or socket path into aValueError(400). Permission errors stay 500s.--allowed-media-domainsand--media-url-max-file-size-mband applied the same way (also to spawned CPU workers):--media-url-timeout: one download timeout for every media loader. Default: unset, so each loader keeps its timeout (REQUEST_TIMEOUTif set, else its own default).--allow-local-media-files(default on;--no-allow-local-media-filesto reject local paths andfile://URLs). Rejection happens before any file probe, so the error does not reveal whether a file exists.Non-base64 digit found.snapshot_media,decode_media_snapshotand the Kimi_load_single_itemmap client media failures toValueError.RuntimeError(500) instead ofValueError.Changes to existing code
Without the new args:
--media-url-max-file-size-mb(64 MiB by default) are rejected; before, local files had no cap.REQUEST_TIMEOUTnow also applies to the Inkling (30 s) and MiMo image (3 s) downloads, and is parsed as a float.#,?or%xxloads the file it names (main checked one path and opened another).cuda_vmm) now get the server's media policy; before they fell back to the defaults.Verification
/dev/zero, directory, missing path, symlink loop, over-cap file, raw/9j/base64, decompression bomb on the artifact path, unreachable URL on the Kimi path, and every loader with--no-allow-local-media-files.cd test && python -m pytest -q registered/unit/multimodal/test_media_input_errors.py registered/unit/models/test_kimi_k25.py registered/unit/test_server_args_migration.py: 79 passed. Every file underregistered/unit/multimodal/,registered/unit/server_args/andregistered/unit/models/test_kimi_k25.pyfails no test that passes on main (local macOS, CPU).CI States
Latest PR Test (Base): 🚫 Run #42931812221
Latest PR Test (Extra): ❌ Run #42931812182
Latest PR Test (AMD ROCm 10): 🚫 Run #42931812284
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: