{"record":{"id":"c02cd96334dddbca","repo":"linshenkx/prompt-optimizer","slug":"example-image-request-failed-resp-status","errorCode":null,"errorMessage":"Example image request failed: ${resp.status}","messagePattern":"Example image request failed: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/ui/src/composables/app/useAppPromptGardenImport.ts","lineNumber":733,"sourceCode":"const resolveGardenUrl = (opts: { gardenBaseUrl: string | null; url: string }): string | null => {\n  const raw = String(opts.url || '').trim()\n  if (!raw) return null\n  if (/^https?:\\/\\//u.test(raw)) return raw\n\n  const base = opts.gardenBaseUrl ? normalizeBaseUrl(opts.gardenBaseUrl) : null\n  if (!base) return null\n\n  try {\n    return new URL(raw, `${base}/`).toString()\n  } catch {\n    return null\n  }\n}\n\nconst fetchImageAsBase64 = async (absoluteUrl: string): Promise<{ b64: string; mimeType: string } | null> => {\n  const resp = await fetch(absoluteUrl, { method: 'GET' })\n  if (!resp.ok) {\n    throw new Error(`Example image request failed: ${resp.status}`)\n  }\n\n  const headerType = resp.headers.get('content-type')\n  const mimeType = typeof headerType === 'string' ? headerType.split(';')[0].trim() : ''\n\n  type BufferLike = {\n    from: (data: ArrayBuffer) => { toString: (encoding: 'base64') => string }\n  }\n\n  const maybeBuffer = (globalThis as unknown as { Buffer?: BufferLike }).Buffer\n  if (maybeBuffer && typeof maybeBuffer.from === 'function') {\n    const ab = await resp.arrayBuffer()\n    const b64 = maybeBuffer.from(ab).toString('base64')\n    return { b64, mimeType: mimeType || 'application/octet-stream' }\n  }\n\n  if (typeof FileReader === 'undefined') {\n    throw new Error('FileReader is not available to decode images')","sourceCodeStart":715,"sourceCodeEnd":751,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/composables/app/useAppPromptGardenImport.ts#L715-L751","documentation":"fetchImageAsBase64 GETs an example image referenced by an imported Garden prompt. If the HTTP response status is not ok (outside 200-299), it throws with the embedded status code. This is a plain network/HTTP failure on a secondary asset, distinct from the prompt JSON fetch.","triggerScenarios":"Any non-2xx status: 404 (image URL stale or deleted), 403 (hotlink protection / expired signed URL), 401 (auth required), 5xx (origin server error), or a CORS-blocked request surfacing as a failure status via the proxy.","commonSituations":"Garden prompts referencing images with expiring signed URLs (S3 presigned links past expiry); CDN hotlink protection; relative image URLs resolved against the wrong base; image deleted upstream after prompt publication.","solutions":["Retry the fetch manually with the exact absoluteUrl to read the status code (404 vs 403 vs 5xx)","If 403 with signed URLs, re-import the prompt soon after export so URLs are fresh, or fix the signing/allowlist","If 404, drop the dead image reference from the prompt or update it to a stable URL","Wrap the import flow so a single failed example image degrades gracefully instead of aborting the whole import"],"exampleFix":"// before\nconst { b64, mimeType } = await fetchImageAsBase64(absoluteUrl)\n\n// after\nlet image: { b64: string; mimeType: string } | null = null\ntry {\n  image = await fetchImageAsBase64(absoluteUrl)\n} catch (err) {\n  console.warn(`Skipping example image (${absoluteUrl}):`, err)\n}","handlingStrategy":"fallback","validationCode":"const probe = await fetch(absoluteUrl, { method: 'HEAD' })\nif (!probe.ok) skipImage(`Image unavailable (HTTP ${probe.status})`)","typeGuard":null,"tryCatchPattern":"try { image = await fetchImageAsBase64(url) } catch (e) { console.warn('Skipping example image:', e); image = null }","preventionTips":["Treat example images as best-effort: import should succeed without them","Use stable, non-expiring image URLs in published prompts","Set up monitoring for broken image links in the Garden backend"],"tags":["network","http-status","image","prompt-garden","fetch"],"backgroundTag":"http-request-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}