musistudio/claude-code-router · error

Compressed CCR media artifacts are not accepted for inline p

Error message

Compressed CCR media artifacts are not accepted for inline preview.

What it means

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.

Source

Thrown at packages/core/src/agents/codex/media-preview-bridge.ts:315

      headers: { accept: "image/*, video/*" },
      redirect: "error",
      signal
    });
  } catch {
    throw new Error("The CCR artifact request failed.");
  }
  if (!response.ok) throw new Error(`The CCR artifact endpoint returned HTTP ${response.status}.`);
  if (response.redirected) throw new Error("The CCR artifact endpoint attempted a redirect.");
  const declaredMimeType = (response.headers.get("content-type") || "").split(";", 1)[0].trim().toLowerCase();
  const declaredKind = mediaKind(declaredMimeType);
  if (!declaredKind) throw new Error("The CCR artifact endpoint returned a non-media content type.");
  const maxBytes = declaredKind === "video" ? codexMediaPreviewMaxVideoBytes : codexMediaPreviewMaxImageBytes;
  const declaredLength = Number(response.headers.get("content-length") || "0");
  if (declaredLength && (!Number.isSafeInteger(declaredLength) || declaredLength < 1 || declaredLength > maxBytes)) {
    throw new Error("The CCR media artifact exceeds the inline preview size limit.");
  }
  if (response.headers.get("content-encoding") && response.headers.get("content-encoding") !== "identity") {
    throw new Error("Compressed CCR media artifacts are not accepted for inline preview.");
  }
  if (!response.body) throw new Error("The CCR artifact response had no body.");
  const reader = response.body.getReader();
  const chunks: Buffer[] = [];
  let total = 0;
  while (true) {
    const part = await reader.read();
    if (part.done) break;
    if (!part.value?.byteLength) continue;
    total += part.value.byteLength;
    if (total > maxBytes) {
      await reader.cancel();
      throw new Error("The CCR media artifact exceeds the inline preview size limit.");
    }
    chunks.push(Buffer.from(part.value));
  }
  if (!total) throw new Error("The CCR artifact response was empty.");
  if (declaredLength && total !== declaredLength) throw new Error("The CCR artifact response length did not match its headers.");

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Disable compression for image/* and video/* responses on the serving endpoint or proxy (compression of already-compressed media is wasteful anyway)
  2. If a proxy is adding the header, configure it to bypass media content types or pass Content-Encoding: identity
  3. Verify with curl --compressed -v that the response arrives uncompressed

Example fix

# nginx: skip compression for media
location /artifacts/ {
  gzip off;
  brotli off;
}
Defensive patterns

Strategy: validation

Validate before calling

async function isIdentityEncoded(url: string): Promise<boolean> {
  const res = await fetch(url, { method: 'HEAD' });
  const enc = res.headers.get('content-encoding');
  return !enc || enc === 'identity';
}

Type guard

function isCompressionRejection(e: unknown): boolean {
  return e instanceof Error && e.message.includes('Compressed CCR media artifacts');
}

Try / catch

try {
  const media = await bridge.artifact(ref);
} catch (e) {
  if (isCompressionRejection(e)) return renderAsLink(ref.url);
  throw e;
}

Prevention

When it happens

Trigger: CCR endpoint or an intermediary compresses the media response with gzip/brotli/deflate, setting Content-Encoding: gzip etc.

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

Related errors


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/4c028d53e0797207. Report an issue: GitHub.