{"record":{"id":"9a73078d38e2ac27","repo":"sgl-project/sglang","slug":"conditions-index-frame-index-must-be-1-or-in","errorCode":null,"errorMessage":"conditions[{index}].frame_index must be -1 or in [0, {frame_count}) after 17n+5 frame alignment, got {semantic_frame_index}","messagePattern":"conditions\\[(.+?)\\]\\.frame_index must be -1 or in \\[0, (.+?)\\) after 17n\\+5 frame alignment, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py","lineNumber":343,"sourceCode":"    keyframe_pixel_indices: list[int] = []\n    seen_keyframe_pixel_indices: dict[int, int] = {}\n    for index, cond in enumerate(canonical[\"conditions\"]):\n        rule = profile.rule_for(\n            role=str(cond[\"role\"]), condition_type=str(cond[\"type\"])\n        )\n        frame_index = cond.get(\"frame_index\")\n        resolved_frame_index = None\n        if rule.requires_frame_index:\n            if frame_index is None:\n                raise ValueError(f\"conditions[{index}].frame_index is required\")\n            semantic_frame_index = int(frame_index)\n            frame_count = int(shape[\"frame_count\"])\n            if semantic_frame_index == -1:\n                resolved_frame_index = frame_count - 1\n            elif 0 <= semantic_frame_index < frame_count:\n                resolved_frame_index = semantic_frame_index\n            else:\n                raise ValueError(\n                    f\"conditions[{index}].frame_index must be -1 or in \"\n                    f\"[0, {frame_count}) after 17n+5 frame alignment, got \"\n                    f\"{semantic_frame_index}\"\n                )\n            previous = seen_keyframe_pixel_indices.get(resolved_frame_index)\n            if previous is not None:\n                raise ValueError(\n                    f\"conditions[{index}].frame_index resolves to \"\n                    f\"{resolved_frame_index}, already bound by \"\n                    f\"conditions[{previous}]\"\n                )\n            seen_keyframe_pixel_indices[resolved_frame_index] = index\n            keyframe_semantic_indices.append(semantic_frame_index)\n            keyframe_pixel_indices.append(resolved_frame_index)\n        materials.append(\n            MiniMaxH3MaterialPlanItem(\n                condition_index=index,\n                role=str(cond[\"role\"]),","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py#L325-L361","documentation":"The semantic frame_index must be -1 (last frame) or a non-negative int strictly below shape['frame_count'] (computed after 17n+5 frame alignment). Anything else raises this ValueError with the offending value.","triggerScenarios":"Passing frame_index >= frame_count (e.g. 17 for a short clip), or a negative index other than -1 such as -2.","commonSituations":"Requesting the last frame by passing an explicit large index instead of -1; frame_count shrinking after the 17n+5 alignment for a very short requested duration, making previously valid indices out of range.","solutions":["Use -1 for the last frame instead of a computed absolute index","Lower the frame_index below the resolved frame_count (recompute frame_count from the request's duration/resolution under 17n+5 alignment)","Increase the requested video length so frame_count exceeds the index"],"exampleFix":"# before\n{\"frame_index\": frame_count}  # off-by-one, out of range\n# after\n{\"frame_index\": -1}  # semantic last frame","handlingStrategy":"validation","validationCode":"assert fi == -1 or 0 <= fi < frame_count, fi","typeGuard":"def in_frame_range(fi: int, frame_count: int) -> bool:\n    return fi == -1 or 0 <= fi < frame_count","tryCatchPattern":null,"preventionTips":["Use -1 for last frame instead of absolute indices","Recompute frame_count after 17n+5 alignment before validating indices"],"tags":["minimax-h3","frame-index","out-of-range"],"backgroundTag":"index-out-of-range","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}