{"record":{"id":"fc6f5f8cad540164","repo":"sgl-project/sglang","slug":"key-field-is-required","errorCode":null,"errorMessage":"{key}.{field} is required","messagePattern":"(.+?)\\.(.+?) is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py","lineNumber":2121,"sourceCode":"\n    @staticmethod\n    def _pos_ids(pos_info: Any, key: str) -> torch.Tensor:\n        if isinstance(pos_info, dict):\n            ids = pos_info.get(\"position_ids\")\n        else:\n            ids = getattr(pos_info, \"position_ids\", None)\n        if ids is None:\n            raise ValueError(f\"{key}.position_ids is required\")\n        return ids.view(-1).to(torch.long)\n\n    @staticmethod\n    def _psp_field(psp: Any, key: str, field: str) -> Any:\n        if isinstance(psp, dict):\n            value = psp.get(field)\n        else:\n            value = getattr(psp, field, None)\n        if value is None:\n            raise ValueError(f\"{key}.{field} is required\")\n        return value\n\n    @staticmethod\n    def _psp_optional_field(psp: Any, field: str) -> Any:\n        if isinstance(psp, dict):\n            return psp.get(field)\n        return getattr(psp, field, None)\n\n    def refine_prompt_embeds(\n        self,\n        prompt_embeds: torch.Tensor,\n        refiner_cu_seqlens: torch.Tensor,\n        *,\n        device: torch.device,\n    ) -> torch.Tensor:\n        \"\"\"Project and refine request-static text conditioning once.\"\"\"\n        self.materialize_mps_non_layer_weights(\n            \"condition_proj\", \"token_refiner.final_norm\"","sourceCodeStart":2103,"sourceCodeEnd":2139,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py#L2103-L2139","documentation":"forward() reads fields from per-modality position/psp structures via _psp_field, which requires the field to exist (dict key or object attribute). The error message names both the modality key and the missing field, e.g. 'audio.psp_lengths is required'.","triggerScenarios":"Passing a psp dict like {\"audio\": {\"psp_lengths\": x}} where 'audio.field_name' is absent — e.g. missing 'psp_values', 'lengths', or similar required companion field.","commonSituations":"Hand-built multimodal batches missing companion fields; schema changes where a field was renamed or made required; partial serialization dropping None-valued keys.","solutions":["Inspect the error's {key}.{field} and add that field with the correct tensor to the input structure","Cross-check against the model's input dataclass / docs for the full required field list per modality","Write a small pre-flight validator that walks required fields before calling forward"],"exampleFix":"# before\npsp = {\"video\": {\"psp_lengths\": lens}}  # missing companion field\n# after\npsp = {\"video\": {\"psp_lengths\": lens, REQUIRED_FIELD: vals}}  # per error message","handlingStrategy":"type-guard","validationCode":"REQUIRED = (\"field_a\", \"field_b\")  # per error message\nfor key, psp in psp_inputs.items():\n    for f in REQUIRED:\n        v = psp.get(f) if isinstance(psp, dict) else getattr(psp, f, None)\n        assert v is not None, f\"{key}.{f}\"","typeGuard":"def psp_complete(psp: Any, fields: tuple) -> bool:\n    for f in fields:\n        v = psp.get(f) if isinstance(psp, dict) else getattr(psp, f, None)\n        if v is None:\n            return False\n    return True","tryCatchPattern":null,"preventionTips":["Mirror the model's input schema in typed dataclasses","Log dropped/None fields during batch construction"],"tags":["input-validation","multimodal","missing-field"],"backgroundTag":"missing-required-input-field","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}