{"record":{"id":"69ffa4844bf2356a","repo":"risingwavelabs/risingwave","slug":"must-have-no-buffer-in-a-list-array","errorCode":null,"errorMessage":"Must have no buffer in a list array","messagePattern":"Must have no buffer in a list array","errorType":"error_code","errorClass":"ArrayError","httpStatus":null,"severity":"error","filePath":"src/common/src/array/list_array.rs","lineNumber":250,"sourceCode":"    ///\n    /// ```text\n    /// [[1,2,3],NULL,[4,5]] => [1,2,3,4,5]\n    /// [[[1],[2]],[[3],[4]]] => [1,2,3,4]\n    /// ```\n    pub fn flatten(&self) -> ArrayImpl {\n        match &*self.value {\n            ArrayImpl::List(inner) => inner.flatten(),\n            a => a.clone(),\n        }\n    }\n\n    /// Return the inner array of the list array.\n    pub fn values(&self) -> &ArrayImpl {\n        &self.value\n    }\n\n    pub fn from_protobuf(array: &PbArray) -> ArrayResult<ArrayImpl> {\n        ensure!(\n            array.values.is_empty(),\n            \"Must have no buffer in a list array\"\n        );\n        debug_assert!(\n            (array.array_type == PbArrayType::List as i32)\n                || (array.array_type == PbArrayType::Map as i32),\n            \"invalid array type for list: {}\",\n            array.array_type\n        );\n        let bitmap: Bitmap = array.get_null_bitmap()?.into();\n        let array_data = array.get_list_array_data()?.to_owned();\n        let flatten_len = match array_data.offsets.last() {\n            Some(&n) => n as usize,\n            None => bail!(\"Must have at least one element in offsets\"),\n        };\n        let value = ArrayImpl::from_protobuf(array_data.value.as_ref().unwrap(), flatten_len)?;\n        let arr = ListArray {\n            bitmap,","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/array/list_array.rs#L232-L268","documentation":"`ListArray::from_protobuf` expects the list array's own protobuf representation to contain no direct value buffers, because list elements are stored nested in `array_data.value`, not in `values`. If `array.values` is non-empty, the payload does not follow the list-array encoding and decoding fails.","triggerScenarios":"Calling `ListArray::from_protobuf(&pb_array)` when `pb_array.values` contains buffers — typically because the payload was produced for a flat array type (e.g. Int32Array) or hand-assembled incorrectly.","commonSituations":"Mislabeling `array_type` so a flat array is decoded as a list; corrupted stream chunks after schema changes; manually constructing PbArray in tests or tools.","solutions":["Confirm the PbArray was produced by `ListArray::to_protobuf`, which leaves `values` empty and fills `array_data` instead.","Verify `array_type` is List or Map before decoding.","Check for version skew where the serialization format of list arrays changed.","Fix test/tooling code that builds PbArray manually to not set `values` for lists."],"exampleFix":"// before (mis-encoded flat array decoded as list)\nlet arr = ListArray::from_protobuf(&pb_array)?;\n// after: route by array type\nmatch pb_array.array_type() {\n    PbArrayType::List | PbArrayType::Map => ListArray::from_protobuf(&pb_array),\n    _ => ArrayImpl::from_protobuf(&pb_array, cardinality),\n}","handlingStrategy":"validation","validationCode":"if !pb_array.values.is_empty() { return Err(\"list array must have no direct buffers\".into()); }","typeGuard":"fn is_list_encoded(a: &PbArray) -> bool {\n    (a.array_type == PbArrayType::List as i32 || a.array_type == PbArrayType::Map as i32) && a.values.is_empty()\n}","tryCatchPattern":null,"preventionTips":["Dispatch decoding by array_type before calling a specific from_protobuf","Use ListArray::to_protobuf for serialization","Add round-trip tests for list/map arrays"],"tags":["rust","array","list","deserialization"],"backgroundTag":"unexpected-response-shape","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}