{"record":{"id":"d26495fd68cc91e8","repo":"sgl-project/sglang","slug":"invalid-modality-modality-in-limit-mm-data-p","errorCode":null,"errorMessage":"Invalid modality '{modality}' in --limit-mm-data-per-request.Allowed modalities are: {list(allowed_modalities)}","messagePattern":"Invalid modality '(.+?)' in --limit-mm-data-per-request\\.Allowed modalities are: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/server_args.py","lineNumber":9659,"sourceCode":"                cuda_graph_config=with_phase(\n                    cfg.cuda_graph_config, Phase.PREFILL, backend=Backend.DISABLED\n                ),\n            )\n            self._declare(\"_handle_other_validations\", skip_server_warmup=True)\n\n        # Validate limit_mm_per_prompt modalities\n        if cfg.limit_mm_data_per_request:\n            if isinstance(cfg.limit_mm_data_per_request, str):\n                self._declare(\n                    \"_handle_other_validations\",\n                    limit_mm_data_per_request=json.loads(cfg.limit_mm_data_per_request),\n                )\n\n            if isinstance(cfg.limit_mm_data_per_request, dict):\n                allowed_modalities = {\"image\", \"video\", \"audio\"}\n                for modality in cfg.limit_mm_data_per_request.keys():\n                    if modality not in allowed_modalities:\n                        raise ValueError(\n                            f\"Invalid modality '{modality}' in --limit-mm-data-per-request.\"\n                            f\"Allowed modalities are: {list(allowed_modalities)}\"\n                        )\n\n        # Validate preferred_sampling_params\n        if cfg.preferred_sampling_params:\n            if isinstance(cfg.preferred_sampling_params, str):\n                self._declare(\n                    \"_handle_other_validations\",\n                    preferred_sampling_params=json.loads(cfg.preferred_sampling_params),\n                )\n\n            # Validate preferred_sampling_params doesn't use tokenizer-dependent features\n            if cfg.skip_tokenizer_init:\n                from sglang.srt.sampling.sampling_params import SamplingParams\n\n                test_params = SamplingParams(**cfg.preferred_sampling_params)\n                # raises if tokenizer-dependent features used","sourceCodeStart":9641,"sourceCodeEnd":9677,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/server_args.py#L9641-L9677","documentation":"Raised while validating --limit-mm-data-per-request when a key in the per-modality limit dict is not one of image, video, audio. The dict maps modality name to a per-request item cap; unknown modality names are rejected.","triggerScenarios":"Passing e.g. --limit-mm-data-per-request '{\"images\": 1}' (plural), '{\"text\": 1}', or any key outside {image, video, audio}.","commonSituations":"Pluralized keys ('images' instead of 'image'); assuming a newer modality (e.g. 'video' variants) is supported in an older SGLang; typos in JSON keys.","solutions":["Use exact keys: image, video, audio","Remove limits for modalities you don't need rather than inventing keys","Check the model's supported modalities before limiting"],"exampleFix":"# before\n--limit-mm-data-per-request '{\"images\": 1}'\n# after\n--limit-mm-data-per-request '{\"image\": 1}'","handlingStrategy":"type-guard","validationCode":"allowed = {'image', 'video', 'audio'}\nif isinstance(args.limit_mm_data_per_request, dict):\n    bad = set(args.limit_mm_data_per_request) - allowed\n    assert not bad, f'invalid modalities: {bad}; allowed: {sorted(allowed)}'","typeGuard":"def valid_mm_limits(d: dict) -> bool:\n    return set(d) <= {'image', 'video', 'audio'}","tryCatchPattern":null,"preventionTips":["Use singular modality keys: image/video/audio","Validate dict keys against the allowed set before launch"],"tags":["sglang","multimodal","limit-mm-per-request","server-args","validation"],"backgroundTag":"enum-value-invalid","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}