{"record":{"id":"86c14331f0e427e0","repo":"databendlabs/databend","slug":"internal-error-entered-unreachable-code-86c143","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/storages/common/table_meta/src/meta/compression.rs","lineNumber":53,"sourceCode":"        match self {\n            Compression::Lz4 => 0,\n            Compression::Lz4Raw => 1,\n            Compression::Snappy => 2,\n            Compression::Zstd => 3,\n            Compression::Gzip => 4,\n            Compression::None => 5,\n        }\n    }\n\n    pub fn from_u8(value: u8) -> Self {\n        match value {\n            0 => Compression::Lz4,\n            1 => Compression::Lz4Raw,\n            2 => Compression::Snappy,\n            3 => Compression::Zstd,\n            4 => Compression::Gzip,\n            5 => Compression::None,\n            _ => unreachable!(),\n        }\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":57,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/storages/common/table_meta/src/meta/compression.rs#L35-L57","documentation":"Compression::from_u8 maps a serialized u8 tag (from segment/snapshot metadata) back to a Compression enum. It panics with unreachable! when the stored byte is not one of the known tags 0..=5. This means the metadata on disk was written by an incompatible (newer) format version or is corrupted.","triggerScenarios":"Reading a segment/snapshot whose serialized compression byte exceeds 5 — e.g. metadata produced by a newer Databend that added a Compression variant, then read by an older binary; or corrupted meta files.","commonSituations":"Downgrade scenarios (new cluster data read by old release); manually edited or damaged table metadata; snapshot/segment files copied between incompatible versions.","solutions":["Upgrade Databend to a version at least as new as the one that wrote the metadata","Check the compression byte in the offending segment/snapshot file for corruption","Restore the table metadata from a backup taken with a compatible version","If you added a new Compression variant, add a matching arm to from_u8 (ideally returning an error instead of panicking)"],"exampleFix":"// before\n_ => unreachable!(),\n// after\nv => Err(ErrorCode::StorageOther(format!(\n    \"unknown compression tag {v} in metadata; table may be from a newer version\"\n))),","handlingStrategy":"fallback","validationCode":"// rust: validate compression byte before decoding\nfn valid_compression_tag(b: u8) -> bool { b <= 5 }","typeGuard":"fn is_known_compression(b: u8) -> bool { b <= 5 }","tryCatchPattern":"// expect a panic from from_u8 on unknown tags; wrap meta load\nlet compression = std::panic::catch_unwind(|| Compression::from_u8(tag))\n    .map_err(|_| \"unknown compression tag; metadata may be from a newer version\")?;","preventionTips":["Avoid downgrading Databend below the version that wrote table metadata","Back up metadata before version changes","Treat unknown enum tags in persisted metadata as errors, not unreachable"],"tags":["rust","panic","compression","metadata","serialization"],"backgroundTag":"invalid-enum-value","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}