{"record":{"id":"5f10d0ab71970c8e","repo":"cube-js/cube","slug":"unhandled-encoding-ordinal","errorCode":null,"errorMessage":"Unhandled encoding ordinal {}","messagePattern":"Unhandled encoding ordinal (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"rust/cubestore/cubehll/src/instance.rs","lineNumber":261,"sourceCode":"                if data.len() != expected_len as usize {\n                    return Err(HllError::new(format!(\n                        \"Expected {} data bytes for encoding FULL with log2m={}, got {}\",\n                        expected_len,\n                        log_num_buckets,\n                        data.len()\n                    )));\n                }\n                let mut values = Vec::with_capacity(num_buckets as usize);\n                let mut cursor = BitCursor::new(data);\n                for _ in 0..num_buckets {\n                    values.push(cursor.read_bits(reg_width as usize).unwrap() as u8)\n                }\n                Ok(HllInstance::Dense(DenseHll::new_from_entries(\n                    log_num_buckets,\n                    values,\n                )?))\n            }\n            enc => panic!(\"Unhandled encoding ordinal {}\", enc),\n        }\n    }\n\n    pub fn read_snowflake(s: &str) -> Result<HllInstance> {\n        #[derive(Deserialize)]\n        struct SerializedHll {\n            precision: u8,\n            version: u8,\n            sparse: Option<SparseEntries>,\n            dense: Option<Vec<u8>>,\n        }\n        #[derive(Deserialize)]\n        #[allow(non_snake_case)]\n        struct SparseEntries {\n            indices: Vec<u32>,\n            maxLzCounts: Vec<u8>,\n        }\n","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cubestore/cubehll/src/instance.rs#L243-L279","documentation":"This panic comes from CubeStore's HLL (HyperLogLog) deserialization in cubehll. When reading a serialized HLL instance, the stored encoding ordinal byte does not match any known encoding (e.g. dense or sparse variants the code knows how to decode), so read fails fast with a panic rather than returning garbage results. It indicates corrupt, truncated, or version-incompatible HLL sketch data.","triggerScenarios":"Calling HllInstance::read (or read_snowflake-adjacent deserialization paths) on bytes whose first/encoding byte is an unrecognized ordinal — typically data written by a newer cubehll version, manually edited/corrupted storage, or bytes not produced by HllInstance serialization at all.","commonSituations":"Upgrading/downgrading CubeStore so on-disk HLL sketches (e.g. approximate distinct-count pre-aggregations) were written with a different encoding ordinal; a corrupted CubeStore metadata/partition file; feeding arbitrary bytes into the deserializer.","solutions":["Verify the CubeStore version that wrote the data matches the version reading it; align versions (upgrade the reader or re-generate data with the current version).","Delete/rebuild the affected HLL sketch data (drop and re-run the pre-aggregation or query so the sketch is recomputed).","If data is suspect, restore CubeStore data files from a backup or re-ingest the source partition.","If you control the code, extend the match in instance.rs to handle the new encoding instead of panicking, or return a proper CubeError."],"exampleFix":"// before\nenc => panic!(\"Unhandled encoding ordinal {}\", enc),\n// after\nenc => return Err(CubeError::internal(format!(\"Unhandled HLL encoding ordinal {}; data may be from an incompatible CubeStore version\", enc))),","handlingStrategy":"validation","validationCode":"// Check encoding ordinal before deserializing an HLL blob\nfn is_known_hll_encoding(bytes: &[u8]) -> bool {\n    !bytes.is_empty() && matches!(bytes[0], 0 | 1) // ordinals handled by this build\n}","typeGuard":"fn looks_like_hll_blob(bytes: &[u8]) -> bool {\n    !bytes.is_empty() && bytes.len() > 1 && bytes[0] <= 1\n}","tryCatchPattern":null,"preventionTips":["Pin and align CubeStore/cubehll versions across writer and reader nodes","Back up CubeStore data before upgrades so sketches can be restored","Treat unexpected ordinals as data corruption: recompute sketches instead of retrying the read","Prefer returning CubeError over panic when modifying the deserializer"],"tags":["rust","cubestore","deserialization","data-corruption","version-mismatch"],"backgroundTag":"hll-encoding-ordinal-unhandled","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}