{"record":{"id":"5931e8a3208189aa","repo":"sgl-project/sglang","slug":"unsupported-kimi-k3-encoder-media-item-image","errorCode":null,"errorMessage":"Unsupported Kimi-K3 encoder media item: {image}","messagePattern":"Unsupported Kimi-K3 encoder media item: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/kimi_k3_image_processing.py","lineNumber":83,"sourceCode":"        \"in_patch_limit\",\n        \"patch_limit_on_one_side\",\n        \"image_mean\",\n        \"image_std\",\n    )\n    missing = [name for name in required if name not in media_proc_cfg]\n    if missing:\n        raise ValueError(\n            \"Kimi-K3 image processor is missing deferred-preprocessing config: \"\n            + \", \".join(missing)\n        )\n\n    concrete_images = []\n    content_digests = []\n    for image in images:\n        content_digest = None\n        if isinstance(image, dict):\n            if image.get(\"type\") != \"image\" or \"image\" not in image:\n                raise ValueError(f\"Unsupported Kimi-K3 encoder media item: {image}\")\n            content_digest = image.get(\"content_hash\")\n            image = image[\"image\"]\n        concrete_images.append(image)\n        content_digests.append(content_digest)\n\n    patch_size = int(media_proc_cfg[\"patch_size\"])\n    merge_kernel_size = int(media_proc_cfg[\"merge_kernel_size\"])\n    deferred_preprocessing = functools.partial(\n        KimiK3DeferredPreprocessing,\n        backend=\"gpu\" if use_gpu_preprocessing else \"cpu\",\n        image_mean=list(media_proc_cfg[\"image_mean\"]),\n        image_std=list(media_proc_cfg[\"image_std\"]),\n        transparent_bg_config=media_proc_cfg.get(\"transparent_bg_config\"),\n    )\n\n    items = []\n    grids = []\n    original_image_sizes = []","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/kimi_k3_image_processing.py#L65-L101","documentation":"prepare_kimi_k3_encoder_inputs accepts per-image items either as raw images or as dicts of the form {'type': 'image', 'image': <payload>, ...}. Any dict that does not have type == 'image' and an 'image' key is rejected with this ValueError, protecting the encoder from unsupported media kinds (e.g. video/audio dicts or malformed entries).","triggerScenarios":"Passing an images list containing a dict like {'type': 'video', ...}, {'type': 'image'} without an 'image' key, or a dict with a differently-named payload key (e.g. 'url' instead of 'image').","commonSituations":"Forwarding an unfiltered chat content list (which contains text/video entries) directly as images; renaming keys when building the request payload; partial refactors of the mm item schema.","solutions":["Filter the content list to items with item.get('type') == 'image' before passing","Ensure each dict has an 'image' key holding the image payload; unwrap raw images if dicts are unnecessary","Normalize other modalities through their own encoder-input preparers instead of this image API"],"exampleFix":"// before\nimages = content  # contains {'type':'text',...}\nprepare_kimi_k3_encoder_inputs(images, cfg)\n// after\nimages = [c for c in content if c.get('type') == 'image']\nprepare_kimi_k3_encoder_inputs(images, cfg)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def is_kimi_k3_image_item(x):\n    return not isinstance(x, dict) or (x.get(\"type\") == \"image\" and \"image\" in x)","tryCatchPattern":"try:\n    prepare_kimi_k3_encoder_inputs(images, cfg)\nexcept ValueError as e:\n    if \"Unsupported Kimi-K3 encoder media item\" in str(e):\n        images = [i for i in images if is_kimi_k3_image_item(i)]\n        prepare_kimi_k3_encoder_inputs(images, cfg)\n    else:\n        raise","preventionTips":["Filter chat content by type=='image' before calling the encoder prep","Keep dict schema exactly {'type':'image','image':payload[,'content_hash':...]}"],"tags":["multimodal","kimi-k3","input-validation"],"backgroundTag":"invalid-request-payload","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}