{"record":{"id":"df0d976ee1074186","repo":"sgl-project/sglang","slug":"unhandled-known-messagepack-extension-code-code","errorCode":null,"errorMessage":"Unhandled known MessagePack extension code: {code}","messagePattern":"Unhandled known MessagePack extension code: (.+?)","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/msgpack_utils.py","lineNumber":248,"sourceCode":"\n    if code == _MSGPACK_EXT_ARRAY:\n        typecode, raw_data = _unpack_buffer_ext(data)\n        res = array(typecode)\n        res.frombytes(raw_data)\n        return res\n    if code == _MSGPACK_EXT_TORCH_TENSOR:\n        metadata, raw_data = _unpack_buffer_ext(data)\n        shape, dtype, device = metadata\n        return _restore_torch_tensor(shape, dtype, raw_data, device)\n    if code == _MSGPACK_EXT_NP_ARRAY:\n        metadata, raw_data = _unpack_buffer_ext(data)\n        shape, dtype = metadata\n        return np.frombuffer(raw_data, dtype=np.dtype(dtype)).copy().reshape(shape)\n    if code == _MSGPACK_EXT_SHM_POINTER_MM_DATA:\n        return _decode_shm_pointer_mm_data(_unpack_ext(data))\n    if code == _MSGPACK_EXT_CUDA_IPC_TENSOR_PROXY:\n        return _decode_cuda_ipc_tensor_proxy(_unpack_ext(data))\n    raise AssertionError(f\"Unhandled known MessagePack extension code: {code}\")\n","sourceCodeStart":230,"sourceCodeEnd":249,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/msgpack_utils.py#L230-L249","documentation":"msgpack_utils registers known extension codes (buffers, shm pointers, CUDA IPC tensor proxies). ext_hook decodes each by code; reaching the raise means the packed data carries a code that matches a known code constant on the receiver but has no decode branch — i.e., malformed or version-skewed wire data.","triggerScenarios":"Unpacking bytes whose ext code equals one of the module's known codes but none of the if-branches handled it, typically from truncated/corrupted payloads or sender/receiver built from different sglang versions.","commonSituations":"Mixed-version processes on the same ZMQ/IPC channel after a partial upgrade; tests feeding hand-crafted malformed ext payloads (the test_malformed_known_buffer_ext_is_rejected caller).","solutions":["Restart all sglang processes from the same installed version so encoder and decoder share ext code tables.","For malformed input, validate/corrupt-test with the dedicated rejection path rather than expecting graceful decode.","If adding a new ext code, remember to add both the ext_hook branch and decoder."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    obj = msgpack.unpackb(data, ext_hook=ext_hook)\nexcept AssertionError as e:\n    raise ValueError(\"corrupted or version-skewed IPC payload\") from e","preventionTips":["Never mix processes from different installs on one ZMQ endpoint.","Fully drain/clean IPC queues when restarting a component."],"tags":["serialization","msgpack","ipc","version-mismatch"],"backgroundTag":"invalid-wire-format","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}