{"record":{"id":"db115849f59f2621","repo":"awslabs/llrt","slug":"unsupported-encoding","errorCode":null,"errorMessage":"unsupported encoding: {}","messagePattern":"unsupported encoding: (.+?)","errorType":"error_code","errorClass":"io::Error (InvalidInput)","httpStatus":null,"severity":"error","filePath":"libs/llrt_compression/src/streaming.rs","lineNumber":39,"sourceCode":"\nimpl StreamingDecoder {\n    pub fn new(encoding: &str) -> io::Result<Self> {\n        match encoding {\n            #[cfg(any(feature = \"flate2-c\", feature = \"flate2-rust\"))]\n            \"gzip\" => Ok(Self::Gzip(flate2::write::GzDecoder::new(Vec::new()))),\n            #[cfg(any(feature = \"flate2-c\", feature = \"flate2-rust\"))]\n            \"deflate\" => Ok(Self::Deflate(flate2::write::ZlibDecoder::new(Vec::new()))),\n            #[cfg(any(feature = \"zstd-c\", feature = \"zstd-rust\"))]\n            \"zstd\" => Ok(Self::Zstd(zstd::stream::write::Decoder::new(Vec::new())?)),\n            #[cfg(feature = \"brotli-c\")]\n            \"br\" => Ok(Self::Brotli(brotlic::DecompressorWriter::new(Vec::new()))),\n            #[cfg(all(not(feature = \"brotli-c\"), feature = \"brotli-rust\"))]\n            \"br\" => Ok(Self::Brotli(brotlic::DecompressorWriter::new(\n                Vec::new(),\n                8_096,\n            ))),\n            \"\" | \"identity\" => Ok(Self::Identity),\n            _ => Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                format!(\"unsupported encoding: {}\", encoding),\n            )),\n        }\n    }\n\n    /// Decompress a chunk of data, returning the decompressed output\n    pub fn decompress_chunk(&mut self, input: &[u8]) -> io::Result<Vec<u8>> {\n        match self {\n            Self::Identity => Ok(input.to_vec()),\n            #[cfg(any(feature = \"flate2-c\", feature = \"flate2-rust\"))]\n            Self::Gzip(decoder) => {\n                decoder.write_all(input)?;\n                decoder.flush()?;\n                Ok(std::mem::take(decoder.get_mut()))\n            },\n            #[cfg(any(feature = \"flate2-c\", feature = \"flate2-rust\"))]\n            Self::Deflate(decoder) => {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/awslabs/llrt/blob/742fc00b82cbeaab1c1b76f0d706c302a5cbc306/libs/llrt_compression/src/streaming.rs#L21-L57","documentation":"This error is returned by StreamingDecompressor::new in llrt_compression when the Content-Encoding string is not a recognized encoding. Recognized values include 'gzip', 'deflate', 'br' (depending on enabled feature flags), '' and 'identity'; anything else produces an io::Error of kind InvalidInput. The format placeholder carries the offending encoding name.","triggerScenarios":"Constructing a streaming decompressor with an encoding string such as 'zstd', 'compress', 'x-gzip', or a misspelled/mixed-case value like 'GZIP' that is not handled by the match.","commonSituations":"Servers returning unusual Content-Encoding headers (zstd, br+gzip), proxies adding encodings this build has no feature flag for, or hand-written header parsing that passes the raw header through without normalization.","solutions":["Normalize the encoding string (lowercase, trim) before passing it in.","Handle 'identity'/'' by skipping decompression instead of constructing a decompressor.","Enable the matching cargo feature (e.g. brotli) if 'br' support was compiled out.","Add an explicit feature-detection step that rejects unknown encodings upstream with a clear message."],"exampleFix":"// before\nlet stream = StreamingDecompressor::new(encoding)?; // encoding = \"zstd\"\n// after\nmatch encoding {\n  \"\" | \"identity\" => stream,\n  \"gzip\" | \"deflate\" | \"br\" => StreamingDecompressor::new(encoding)?,\n  other => return Err(unsupported(other)),\n}","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['gzip', 'deflate', 'br', '', 'identity'];\nconst enc = (encoding ?? '').toLowerCase().trim();\nif (!SUPPORTED.includes(enc)) throw new Error('unsupported encoding: ' + enc);","typeGuard":"function isSupportedEncoding(e) {\n  return ['gzip', 'deflate', 'br', '', 'identity'].includes(String(e).toLowerCase().trim());\n}","tryCatchPattern":"match StreamingDecompressor::new(enc) {\n    Ok(s) => s,\n    Err(e) if e.kind() == io::ErrorKind::InvalidInput => pass_through_identity(),\n    Err(e) => return Err(e),\n}","preventionTips":["Normalize Content-Encoding values (lowercase/trim) before use.","Treat '' and 'identity' as no-op; skip decompressor creation.","Verify brotli/zstd feature flags match the encodings your services emit."],"tags":["compression","encoding","invalid-input"],"backgroundTag":"invalid-enum-value","analyzedSha":"742fc00b82cbeaab1c1b76f0d706c302a5cbc306","analyzedAt":"2026-09-12T11:14:07.838Z","contentChangedAt":"2026-09-12T11:14:07.838Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}