{"record":{"id":"27031a5a35f1a46e","repo":"FuelLabs/fuel-core","slug":"compression-level-value-outside-of-allowed-range","errorCode":null,"errorMessage":"Compression level {value} outside of allowed range 0..=22","messagePattern":"Compression level (.+?) outside of allowed range 0\\.\\.=22","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/chain-config/src/config/state/writer.rs","lineNumber":101,"sourceCode":"            6 => Ok(Self::Level6),\n            7 => Ok(Self::Level7),\n            8 => Ok(Self::Level8),\n            9 => Ok(Self::Level9),\n            10 => Ok(Self::Level10),\n            11 => Ok(Self::Level11),\n            12 => Ok(Self::Level12),\n            13 => Ok(Self::Level13),\n            14 => Ok(Self::Level14),\n            15 => Ok(Self::Level15),\n            16 => Ok(Self::Level16),\n            17 => Ok(Self::Level17),\n            18 => Ok(Self::Level18),\n            19 => Ok(Self::Level19),\n            20 => Ok(Self::Level20),\n            21 => Ok(Self::Level21),\n            22 => Ok(Self::Max),\n            _ => {\n                anyhow::bail!(\"Compression level {value} outside of allowed range 0..=22\")\n            }\n        }\n    }\n}\n\n#[cfg(feature = \"parquet\")]\nimpl From<ZstdCompressionLevel> for u8 {\n    fn from(value: ZstdCompressionLevel) -> Self {\n        match value {\n            ZstdCompressionLevel::Uncompressed => 0,\n            ZstdCompressionLevel::Level1 => 1,\n            ZstdCompressionLevel::Level2 => 2,\n            ZstdCompressionLevel::Level3 => 3,\n            ZstdCompressionLevel::Level4 => 4,\n            ZstdCompressionLevel::Level5 => 5,\n            ZstdCompressionLevel::Level6 => 6,\n            ZstdCompressionLevel::Level7 => 7,\n            ZstdCompressionLevel::Level8 => 8,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/chain-config/src/config/state/writer.rs#L83-L119","documentation":"ZstdCompressionLevel::try_from maps each input value to one of 23 enum variants (Uncompressed=0 through Max=22) and rejects anything else with 'Compression level {value} outside of allowed range 0..=22' (crates/chain-config/src/config/state/writer.rs:101). This is a strict config-validation error: the level came from user configuration/CLI and is not an accepted zstd level in this crate. It fails at construction time, before any snapshot I/O.","triggerScenarios":"Constructing the snapshot writer with a compression level greater than 22 (e.g. 23+) or otherwise out of range, then ZstdCompressionLevel::try_from(value)? rejects it.","commonSituations":"Copying zstd CLI conventions (zstd --ultra accepts up to 22; anything above has no equivalent here); config parsed from env vars without bounds checking; tooling that generates chain-config writer settings with arbitrary integers.","solutions":["Set the compression level to a value in 0..=22 (3 is a balanced default; 22 is max).","Validate or clamp the level where configuration is loaded: `let level = value.min(22);` if you accept loose input.","Remember every fragment must use the same level — fix the setting wherever fragments are produced, not just the merger."],"exampleFix":"// before\nlet level = ZstdCompressionLevel::try_from(requested_level)?; // 23 → error\n\n// after\nanyhow::ensure!(\n    requested_level <= 22,\n    \"zstd compression level must be 0..=22, got {requested_level}\"\n);\nlet level = ZstdCompressionLevel::try_from(requested_level)?;","handlingStrategy":"validation","validationCode":"anyhow::ensure!(\n    (0..=22).contains(&level),\n    \"zstd compression level must be 0..=22, got {level}\"\n);\nlet level = ZstdCompressionLevel::try_from(level)?;","typeGuard":"fn is_valid_zstd_level(value: u8) -> bool {\n    matches!(value, 0..=22)\n}","tryCatchPattern":null,"preventionTips":["Validate the level at config load time with a clear message naming the setting.","Clamp loose input (CLI/env) to 0..=22 before construction.","Use one shared level value everywhere fragments and writers are created."],"tags":["rust","fuel-core","chain-config","zstd","compression","configuration"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}