{"record":{"id":"4c397caa1f405eab","repo":"remix-run/remix","slug":"unsupported-encoding-encoding","errorCode":null,"errorMessage":"Unsupported encoding: ${encoding}","messagePattern":"Unsupported encoding: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/response/src/lib/compress.ts","lineNumber":367,"sourceCode":"      compressor.destroy()\n      await reader?.cancel(reason)\n    },\n  })\n}\n\nfunction createCompressor(\n  encoding: Encoding,\n  options: CompressResponseOptions,\n): Gzip | Deflate | BrotliCompress {\n  switch (encoding) {\n    case 'br':\n      return createBrotliCompress(options.brotli)\n    case 'gzip':\n      return createGzip(options.zlib)\n    case 'deflate':\n      return createDeflate(options.zlib)\n    default:\n      throw new Error(`Unsupported encoding: ${encoding}`)\n  }\n}\n","sourceCodeStart":349,"sourceCodeEnd":370,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/response/src/lib/compress.ts#L349-L370","documentation":"The response compression helper maps an `encoding` value to a zlib compressor and only supports 'br', 'gzip', and 'deflate'. The switch reached its default branch, meaning an unrecognized encoding string was passed. This is a programming/config error in how the compressor was requested, not a runtime environment issue.","triggerScenarios":"Calling the compress API (createCompressor / the `compressor` helper) with an `encoding` other than 'br'/'brotli', 'gzip', or 'deflate' — e.g. 'zstd', 'identity', an empty string, or a value sourced from a request Accept-Encoding header without filtering.","commonSituations":"Forwarding a client's Accept-Encoding header directly as the chosen encoding; adding zstd support before the library supports it; case mismatches like 'GZIP' from a custom config.","solutions":["Pass only 'br', 'gzip', or 'deflate'","If deriving from Accept-Encoding, parse and pick from the supported set before calling","Normalize case (lowercase) before passing the value","File/await support for additional encodings rather than bypassing the guard"],"exampleFix":"// before\nlet compressor = createCompressor(request.headers.get('accept-encoding'))\n\n// after\nlet accepted = request.headers.get('accept-encoding') ?? ''\nlet encoding = ['br','gzip','deflate'].find(e => accepted.includes(e)) ?? 'gzip'\nlet compressor = createCompressor(encoding)","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set(['br', 'gzip', 'deflate'])\nlet encoding = rawEncoding.toLowerCase()\nif (!SUPPORTED.has(encoding)) encoding = 'gzip'","typeGuard":"function isSupportedEncoding(value: string): value is 'br' | 'gzip' | 'deflate' {\n  return value === 'br' || value === 'gzip' || value === 'deflate'\n}","tryCatchPattern":null,"preventionTips":["Never pass Accept-Encoding verbatim; negotiate first","Centralize encoding choice in one helper","Lowercase before comparing"],"tags":["compression","encoding","response","zlib"],"backgroundTag":"unsupported-encoding","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}