musistudio/claude-code-router · error
Artifact URL does not use the CCR media artifact path.
Error message
Artifact URL does not use the CCR media artifact path.
What it means
validateCodexMediaArtifactUrl requires the URL pathname to start with the constant MEDIA_ARTIFACT_PATH_PREFIX (the CCR media artifact route). Any other path is rejected so the loader can only ever fetch known artifact endpoints from the gateway.
Source
Thrown at packages/core/src/agents/codex/media-preview-bridge.ts:278
lastError = error;
}
await sleep(codexMediaPreviewPollIntervalMs);
}
throw new Error(`Codex App CDP page target was not available${lastError ? `: ${redactBridgeError(lastError)}` : "."}`);
}
function isCodexAppPageTarget(target: DevToolsTarget): boolean {
if (target.type !== "page" || !target.webSocketDebuggerUrl) return false;
const url = target.url || "";
return url.startsWith("app://codex") || url.startsWith("app://chatgpt") || /\b(codex|chatgpt)\b/i.test(target.title || "");
}
function validateCodexMediaArtifactUrl(value: string, endpoint: string): ValidatedArtifactUrl {
const expected = new URL(endpoint);
const url = new URL(value);
if (url.protocol !== "http:" || url.origin !== expected.origin) throw new Error("Artifact origin is not the configured CCR gateway.");
if (url.username || url.password || url.hash) throw new Error("Artifact URL contains unsupported credentials or fragments.");
if (!url.pathname.startsWith(MEDIA_ARTIFACT_PATH_PREFIX)) throw new Error("Artifact URL does not use the CCR media artifact path.");
const encodedId = url.pathname.slice(MEDIA_ARTIFACT_PATH_PREFIX.length);
if (!encodedId || encodedId.includes("/")) throw new Error("Artifact URL contains an invalid identifier.");
const artifactId = decodeURIComponent(encodedId);
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(artifactId)) {
throw new Error("Artifact URL contains an invalid identifier.");
}
const keys = [...url.searchParams.keys()];
const token = url.searchParams.get("token") || "";
if (keys.length !== 1 || keys[0] !== "token" || !/^[A-Za-z0-9_-]{32}$/.test(token)) {
throw new Error("Artifact URL contains an invalid access token.");
}
return { artifactId, url };
}
async function loadCodexMediaArtifact(validated: ValidatedArtifactUrl, signal: AbortSignal): Promise<LoadedMediaArtifact> {
let response: Response;
try {
response = await fetch(validated.url, {View on GitHub (pinned to 99f24806c6)
Solutions
- Use artifact URLs exactly as issued by the gateway's media artifact endpoint
- If the gateway route changed, update MEDIA_ARTIFACT_PATH_PREFIX (or upgrade this package) to match the deployed gateway version
- Check reverse-proxy rewrite rules so the artifact path prefix survives proxying
Example fix
// before
validateCodexMediaArtifactUrl("http://gw/files/uuid?token=...", endpoint);
// after
validateCodexMediaArtifactUrl(`http://gw${MEDIA_ARTIFACT_PATH_PREFIX}uuid?token=...`, endpoint); Defensive patterns
Strategy: validation
Validate before calling
import { MEDIA_ARTIFACT_PATH_PREFIX } from '...';
if (!new URL(artifactUrl).pathname.startsWith(MEDIA_ARTIFACT_PATH_PREFIX)) {
throw new Error('rejecting non-artifact path');
} Type guard
function isArtifactPath(value: string, prefix: string): boolean {
try { return new URL(value).pathname.startsWith(prefix); } catch { return false; }
} Prevention
- Only use gateway-issued artifact URLs verbatim
- Keep gateway and client versions in lockstep so route prefixes match
- Check proxy rewrites don't alter the artifact path
When it happens
Trigger: Passing a URL on the correct gateway origin but with a different path, e.g. /api/media, /files/<id>, or a path missing the required prefix; also triggered by trailing-slash or case differences if they break the startsWith check.
Common situations: Artifact URLs from an older/newer gateway version that changed its route; hand-constructed URLs; reverse proxy that rewrites paths and strips or alters the prefix.
Related errors
- Artifact origin is not the configured CCR gateway.
- Artifact URL contains unsupported credentials or fragments.
- Artifact URL contains an invalid identifier.
- Artifact URL contains an invalid access token.
- No available models. Configure at least one provider with a
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/3d4bad5d76be7afc.
Report an issue: GitHub.