{"record":{"id":"4c028d53e0797207","repo":"musistudio/claude-code-router","slug":"compressed-ccr-media-artifacts-are-not-accepted-fo","errorCode":null,"errorMessage":"Compressed CCR media artifacts are not accepted for inline preview.","messagePattern":"Compressed CCR media artifacts are not accepted for inline preview\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/codex/media-preview-bridge.ts","lineNumber":315,"sourceCode":"      headers: { accept: \"image/*, video/*\" },\n      redirect: \"error\",\n      signal\n    });\n  } catch {\n    throw new Error(\"The CCR artifact request failed.\");\n  }\n  if (!response.ok) throw new Error(`The CCR artifact endpoint returned HTTP ${response.status}.`);\n  if (response.redirected) throw new Error(\"The CCR artifact endpoint attempted a redirect.\");\n  const declaredMimeType = (response.headers.get(\"content-type\") || \"\").split(\";\", 1)[0].trim().toLowerCase();\n  const declaredKind = mediaKind(declaredMimeType);\n  if (!declaredKind) throw new Error(\"The CCR artifact endpoint returned a non-media content type.\");\n  const maxBytes = declaredKind === \"video\" ? codexMediaPreviewMaxVideoBytes : codexMediaPreviewMaxImageBytes;\n  const declaredLength = Number(response.headers.get(\"content-length\") || \"0\");\n  if (declaredLength && (!Number.isSafeInteger(declaredLength) || declaredLength < 1 || declaredLength > maxBytes)) {\n    throw new Error(\"The CCR media artifact exceeds the inline preview size limit.\");\n  }\n  if (response.headers.get(\"content-encoding\") && response.headers.get(\"content-encoding\") !== \"identity\") {\n    throw new Error(\"Compressed CCR media artifacts are not accepted for inline preview.\");\n  }\n  if (!response.body) throw new Error(\"The CCR artifact response had no body.\");\n  const reader = response.body.getReader();\n  const chunks: Buffer[] = [];\n  let total = 0;\n  while (true) {\n    const part = await reader.read();\n    if (part.done) break;\n    if (!part.value?.byteLength) continue;\n    total += part.value.byteLength;\n    if (total > maxBytes) {\n      await reader.cancel();\n      throw new Error(\"The CCR media artifact exceeds the inline preview size limit.\");\n    }\n    chunks.push(Buffer.from(part.value));\n  }\n  if (!total) throw new Error(\"The CCR artifact response was empty.\");\n  if (declaredLength && total !== declaredLength) throw new Error(\"The CCR artifact response length did not match its headers.\");","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/agents/codex/media-preview-bridge.ts#L297-L333","documentation":"The artifact response carries a Content-Encoding other than 'identity' (e.g. gzip or br). Because the size and byte-scanning logic (magic-byte sniffing via detectMediaMimeType) assumes uncompressed bytes, compressed responses are rejected outright.","triggerScenarios":"CCR endpoint or an intermediary compresses the media response with gzip/brotli/deflate, setting Content-Encoding: gzip etc.","commonSituations":"Reverse proxies (nginx/Cloudflare) with compression enabled for image/video content types; servers that apply compression globally; negotiation via Accept-Encoding from an HTTP client library.","solutions":["Disable compression for image/* and video/* responses on the serving endpoint or proxy (compression of already-compressed media is wasteful anyway)","If a proxy is adding the header, configure it to bypass media content types or pass Content-Encoding: identity","Verify with curl --compressed -v that the response arrives uncompressed"],"exampleFix":"# nginx: skip compression for media\nlocation /artifacts/ {\n  gzip off;\n  brotli off;\n}","handlingStrategy":"validation","validationCode":"async function isIdentityEncoded(url: string): Promise<boolean> {\n  const res = await fetch(url, { method: 'HEAD' });\n  const enc = res.headers.get('content-encoding');\n  return !enc || enc === 'identity';\n}","typeGuard":"function isCompressionRejection(e: unknown): boolean {\n  return e instanceof Error && e.message.includes('Compressed CCR media artifacts');\n}","tryCatchPattern":"try {\n  const media = await bridge.artifact(ref);\n} catch (e) {\n  if (isCompressionRejection(e)) return renderAsLink(ref.url);\n  throw e;\n}","preventionTips":["Disable proxy compression for image/* and video/* responses","Send Accept-Encoding: identity if you control the requesting stack","Monitor response headers through every intermediary"],"tags":["content-encoding","compression","validation","media"],"backgroundTag":"unexpected-content-encoding","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}