FuelLabs/fuel-core · error

Compression level {value} outside of allowed range 0..=22

Error message

Compression level {value} outside of allowed range 0..=22

What it means

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.

Source

Thrown at crates/chain-config/src/config/state/writer.rs:101

            6 => Ok(Self::Level6),
            7 => Ok(Self::Level7),
            8 => Ok(Self::Level8),
            9 => Ok(Self::Level9),
            10 => Ok(Self::Level10),
            11 => Ok(Self::Level11),
            12 => Ok(Self::Level12),
            13 => Ok(Self::Level13),
            14 => Ok(Self::Level14),
            15 => Ok(Self::Level15),
            16 => Ok(Self::Level16),
            17 => Ok(Self::Level17),
            18 => Ok(Self::Level18),
            19 => Ok(Self::Level19),
            20 => Ok(Self::Level20),
            21 => Ok(Self::Level21),
            22 => Ok(Self::Max),
            _ => {
                anyhow::bail!("Compression level {value} outside of allowed range 0..=22")
            }
        }
    }
}

#[cfg(feature = "parquet")]
impl From<ZstdCompressionLevel> for u8 {
    fn from(value: ZstdCompressionLevel) -> Self {
        match value {
            ZstdCompressionLevel::Uncompressed => 0,
            ZstdCompressionLevel::Level1 => 1,
            ZstdCompressionLevel::Level2 => 2,
            ZstdCompressionLevel::Level3 => 3,
            ZstdCompressionLevel::Level4 => 4,
            ZstdCompressionLevel::Level5 => 5,
            ZstdCompressionLevel::Level6 => 6,
            ZstdCompressionLevel::Level7 => 7,
            ZstdCompressionLevel::Level8 => 8,

View on GitHub (pinned to b9d4d170da)

Solutions

  1. Set the compression level to a value in 0..=22 (3 is a balanced default; 22 is max).
  2. Validate or clamp the level where configuration is loaded: `let level = value.min(22);` if you accept loose input.
  3. Remember every fragment must use the same level — fix the setting wherever fragments are produced, not just the merger.

Example fix

// before
let level = ZstdCompressionLevel::try_from(requested_level)?; // 23 → error

// after
anyhow::ensure!(
    requested_level <= 22,
    "zstd compression level must be 0..=22, got {requested_level}"
);
let level = ZstdCompressionLevel::try_from(requested_level)?;
Defensive patterns

Strategy: validation

Validate before calling

anyhow::ensure!(
    (0..=22).contains(&level),
    "zstd compression level must be 0..=22, got {level}"
);
let level = ZstdCompressionLevel::try_from(level)?;

Type guard

fn is_valid_zstd_level(value: u8) -> bool {
    matches!(value, 0..=22)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FuelLabs/fuel-core@b9d4d170da (2026-08-16). Data as JSON: /api/errors/27031a5a35f1a46e. Report an issue: GitHub.