nexu-io/open-design · error · Error
${providerTag} media fetch ${mediaResp.status}
Error message
${providerTag} media fetch ${mediaResp.status} What it means
Thrown by bytesFromOpenAICompatibleData when the entry carries entry.url and the follow-up fetch of that URL returns non-2xx. Mirrors the first-party 'openai image fetch' path but applies to any OpenAI-compatible gateway that chooses url-style responses over inline b64_json.
Source
Thrown at apps/daemon/src/media/index.ts:1149
return JSON.parse(text);
} catch {
throw new Error(`${providerTag} non-JSON response: ${truncate(text, 200)}`);
}
}
async function bytesFromOpenAICompatibleData(data: any, providerTag: string, requestInit: MediaRequestInit = {}): Promise<Buffer> {
const entry = data && Array.isArray(data.data) ? data.data[0] : null;
if (!entry) throw new Error(`${providerTag} response had no data[0]`);
if (typeof entry.b64_json === 'string' && entry.b64_json) {
const raw = entry.b64_json.includes(',')
? entry.b64_json.slice(entry.b64_json.indexOf(',') + 1)
: entry.b64_json;
return Buffer.from(raw, 'base64');
}
if (typeof entry.url === 'string' && entry.url) {
const mediaResp = await fetch(entry.url, requestInit);
if (!mediaResp.ok) {
throw new Error(`${providerTag} media fetch ${mediaResp.status}`);
}
const arr = await mediaResp.arrayBuffer();
return Buffer.from(arr);
}
throw new Error(`${providerTag} response had neither b64_json nor url`);
}
function imageRouterSizeFor(aspect: string | undefined, surface: 'image' | 'video'): string {
if (surface === 'video') {
if (aspect === '1:1') return '1024x1024';
if (aspect === '9:16') return '576x1024';
if (aspect === '4:3') return '1024x768';
if (aspect === '3:4') return '768x1024';
return '1024x576';
}
if (aspect === '16:9') return '1024x576';
if (aspect === '9:16') return '576x1024';
if (aspect === '4:3') return '1024x768';View on GitHub (pinned to 5be4028344)
Solutions
- Retry — signed-URL fetch failures are often transient.
- Prefer a gateway/model configuration that returns b64_json inline so no secondary fetch is needed.
- Allowlist the gateway's blob/CDN host in egress rules.
- If the gateway exposes a 'response_format=b64_json' option, set it.
Example fix
// before: gateway returns url, blob host blocked // after: force b64_json via the gateway's request option (renderer config) body.response_format = 'b64_json';
Defensive patterns
Strategy: retry
Try / catch
try {
return await bytesFromOpenAICompatibleData(data, providerTag, requestInit);
} catch (err) {
const m = err instanceof Error ? err.message : '';
if (m.endsWith('media fetch ')) {
// signed-URL download failed — retry once, then prefer b64_json
await sleep(backoffMs);
return await bytesFromOpenAICompatibleData(data, providerTag, requestInit);
}
throw err;
} Prevention
- Prefer gateways/models that return b64_json inline to avoid the secondary fetch entirely.
- Allowlist the gateway's blob/CDN host in egress rules.
- Treat signed-URL fetch failures as transient — retry before escalating.
When it happens
Trigger: Gateway returns a short-lived signed URL that expires before download; the gateway's blob host is unreachable from the daemon host; CDN rate-limiting on the secondary fetch.
Common situations: High-latency link causing URL expiry; egress firewall allows the API host but blocks the blob host; gateway returns URLs to a private network.
Related errors
- openai image fetch ${imgResp.status}
- ${providerTag} ${resp.status}: ${truncate(text, 240)}
- ${providerTag} response had no data[0]
- ${providerTag} response had neither b64_json nor url
- ${providerTag} non-JSON response: ${truncate(text, 200)}
AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12).
Data as JSON: /api/errors/f4d1019838aafdb1.
Report an issue: GitHub.