{"record":{"id":"a7145444cab7c0f5","repo":"nexu-io/open-design","slug":"providertag-response-had-neither-b64-json-nor-u","errorCode":null,"errorMessage":"${providerTag} response had neither b64_json nor url","messagePattern":"(.+?) response had neither b64_json nor url","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":1154,"sourceCode":"\nasync function bytesFromOpenAICompatibleData(data: any, providerTag: string, requestInit: MediaRequestInit = {}): Promise<Buffer> {\n  const entry = data && Array.isArray(data.data) ? data.data[0] : null;\n  if (!entry) throw new Error(`${providerTag} response had no data[0]`);\n  if (typeof entry.b64_json === 'string' && entry.b64_json) {\n    const raw = entry.b64_json.includes(',')\n      ? entry.b64_json.slice(entry.b64_json.indexOf(',') + 1)\n      : entry.b64_json;\n    return Buffer.from(raw, 'base64');\n  }\n  if (typeof entry.url === 'string' && entry.url) {\n    const mediaResp = await fetch(entry.url, requestInit);\n    if (!mediaResp.ok) {\n      throw new Error(`${providerTag} media fetch ${mediaResp.status}`);\n    }\n    const arr = await mediaResp.arrayBuffer();\n    return Buffer.from(arr);\n  }\n  throw new Error(`${providerTag} response had neither b64_json nor url`);\n}\n\nfunction imageRouterSizeFor(aspect: string | undefined, surface: 'image' | 'video'): string {\n  if (surface === 'video') {\n    if (aspect === '1:1') return '1024x1024';\n    if (aspect === '9:16') return '576x1024';\n    if (aspect === '4:3') return '1024x768';\n    if (aspect === '3:4') return '768x1024';\n    return '1024x576';\n  }\n  if (aspect === '16:9') return '1024x576';\n  if (aspect === '9:16') return '576x1024';\n  if (aspect === '4:3') return '1024x768';\n  if (aspect === '3:4') return '768x1024';\n  return '1024x1024';\n}\n\n/**","sourceCodeStart":1136,"sourceCodeEnd":1172,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L1136-L1172","documentation":"Thrown by bytesFromOpenAICompatibleData when data[0] exists but has neither a non-empty b64_json nor a non-empty url. The OpenAI-compatible entry contract requires exactly one; absence of both indicates a malformed entry — typically a moderation refusal, a partial/beta response, or a gateway that returns metadata-only entries.","triggerScenarios":"Content moderation refusal that still returns an entry; gateway returns an entry with only a revised_prompt field; beta model returning a placeholder entry; misrouted request to a non-image endpoint that happens to share the {data:[...]} envelope.","commonSituations":"Safety filter tripped; preview model with incomplete response schema; gateway error masquerading as a successful entry.","solutions":["Log data[0] fully to see which fields it carries, then map the renderer to the correct field name.","Rephrase the prompt to avoid moderation triggers.","Switch to a GA model id with a stable b64_json/url response.","Reconfigure the gateway to return inline image bytes."],"exampleFix":"// before: gateway returns {data:[{revised_prompt:'...'}]} only\n// after: switch to a model that returns {data:[{b64_json:'...'}]}\nod media generate --surface image --model <ga-image-model> --prompt \"...\"","handlingStrategy":"type-guard","validationCode":"function hasCompatibleEntryBytes(entry: unknown): boolean {\n  return Boolean(entry && typeof entry === 'object' && (((entry as any).b64_json && typeof (entry as any).b64_json === 'string') || ((entry as any).url && typeof (entry as any).url === 'string')));\n}","typeGuard":"function hasCompatibleEntryBytes(entry: unknown): entry is { b64_json?: string; url?: string } {\n  return Boolean(entry && typeof entry === 'object' && (((entry as any).b64_json && typeof (entry as any).b64_json === 'string') || ((entry as any).url && typeof (entry as any).url === 'string')));\n}","tryCatchPattern":"try {\n  return await bytesFromOpenAICompatibleData(data, providerTag, requestInit);\n} catch (err) {\n  const m = err instanceof Error ? err.message : '';\n  if (m.endsWith('response had neither b64_json nor url')) {\n    // often moderation or schema skew; do not retry the same prompt blindly\n    throw new UserActionableError(`${providerTag}: image entry had no bytes (possibly moderation). Rephrase or switch model.`);\n  }\n  throw err;\n}","preventionTips":["Avoid prompts likely to trip moderation when this fires repeatedly.","Prefer GA model ids whose entry schema is stable.","Log the full entry to detect gateways that return metadata-only entries."],"tags":["network","media","openai-compatible","response-shape","moderation","imagerouter"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}