{"record":{"id":"8066df14218f992b","repo":"sgl-project/sglang","slug":"path-kind-must-be-a-non-empty-string","errorCode":null,"errorMessage":"{path}.kind must be a non-empty string","messagePattern":"(.+?)\\.kind must be a non-empty string","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_sequence.py","lineNumber":321,"sourceCode":"    Comfy's hybrid Ref2VA + guide layout. Video-bearing blocks pack their audio\n    rows immediately before their video rows; both share the same temporal\n    origin and advance by the longer of the audio and video spans. Standalone\n    audio advances the target origin by its own T, and image blocks advance it\n    by one integer slot.\n    \"\"\"\n    if not isinstance(ref_blocks, Sequence) or isinstance(ref_blocks, (str, bytes)):\n        raise ValueError(\"ref_blocks must be a sequence\")\n\n    parsed: list[dict[str, object]] = []\n    ref_visual_rows = 0\n    ref_audio_rows = 0\n    for index, raw in enumerate(ref_blocks):\n        path = f\"ref_blocks[{index}]\"\n        if not isinstance(raw, Mapping):\n            raise ValueError(f\"{path} must be an object\")\n        kind = raw.get(\"kind\", raw.get(\"type\"))\n        if not isinstance(kind, str) or not kind:\n            raise ValueError(f\"{path}.kind must be a non-empty string\")\n        if kind == \"image\":\n            rh = _positive_int(raw, \"latent_h\", path)\n            rw = _positive_int(raw, \"latent_w\", path)\n            rows = (rh // _PATCH_H) * (rw // _PATCH_W)\n            item = {\"kind\": kind, \"latent_h\": rh, \"latent_w\": rw, \"rows\": rows}\n            ref_visual_rows += rows\n        elif kind == \"audio\":\n            rt = _positive_int(raw, \"ref_audio_t\", path, allow_zero=True)\n            rows = rt * audio_channel\n            item = {\"kind\": kind, \"ref_audio_t\": rt, \"audio_rows\": rows}\n            ref_audio_rows += rows\n        elif kind in (\"video\", \"video_audio\"):\n            rt = _positive_int(raw, \"ref_audio_t\", path, allow_zero=True)\n            vt = _positive_int(raw, \"latent_t\", path)\n            vh = _positive_int(raw, \"latent_h\", path)\n            vw = _positive_int(raw, \"latent_w\", path)\n            frame_rows = (vh // _PATCH_H) * (vw // _PATCH_W)\n            audio_rows = rt * audio_channel","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_sequence.py#L303-L339","documentation":"The ref2va packed-sequence builder validates each entry of ref_blocks and requires a non-empty string under the 'kind' (or legacy 'type') key. This ValueError fires when an entry is a Mapping but its kind field is missing, None, or an empty/non-string value. It exists to fail fast before any layout math, since downstream code dispatches on kind ('image', 'audio', 'video').","triggerScenarios":"Calling minimax_h3_packed_sequence_ref2va_blocks (directly or via _build_packed_layout/_branch) with ref_blocks containing an entry like {}, {'kind': None}, {'kind': ''}, {'kind': 3}, or an entry that only uses a key other than 'kind'/'type'.","commonSituations":"Building ref_blocks from loosely-typed user JSON or an LLM-generated media spec; renaming the discriminator key in a schema migration; an entry that uses 'media_type' or 'modality' instead of 'kind'/'type'.","solutions":["Set a non-empty 'kind' string on every ref_blocks entry (accepted values: image, audio, video).","If your payload uses 'type', that alias is accepted — otherwise rename your key to 'kind'.","Add a preflight pass that rejects ref_blocks entries without a valid kind before calling the packer."],"exampleFix":"# before\nref_blocks = [{\"media_type\": \"image\", \"latent_h\": 32, \"latent_w\": 32}]\n\n# after\nref_blocks = [{\"kind\": \"image\", \"latent_h\": 32, \"latent_w\": 32}]","handlingStrategy":"validation","validationCode":"def validate_ref_blocks(ref_blocks):\n    for i, raw in enumerate(ref_blocks):\n        kind = raw.get(\"kind\", raw.get(\"type\")) if isinstance(raw, Mapping) else None\n        if not isinstance(kind, str) or not kind:\n            raise ValueError(f\"ref_blocks[{i}] missing non-empty 'kind'\")","typeGuard":"from collections.abc import Mapping\n\ndef is_valid_ref_block(raw) -> bool:\n    return (\n        isinstance(raw, Mapping)\n        and isinstance(raw.get(\"kind\", raw.get(\"type\")), str)\n        and bool(raw.get(\"kind\", raw.get(\"type\")))\n    )","tryCatchPattern":null,"preventionTips":["Validate ref_blocks against a JSON schema with required kind enum before dispatching to the packer.","Keep ref_blocks producers and the packer on the same key naming ('kind' preferred, 'type' legacy)."],"tags":["validation","schema","multimodal","minimax-h3"],"backgroundTag":"schema-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}