{"record":{"id":"b9293f45697ad203","repo":"vercel/ai","slug":"fireworks-poll-response-is-ready-but-missing-resul","errorCode":null,"errorMessage":"Fireworks poll response is Ready but missing result.sample","messagePattern":"Fireworks poll response is Ready but missing result\\.sample","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/fireworks/src/fireworks-image-model.ts","lineNumber":367,"sourceCode":"        url: pollUrl,\n        headers,\n        body: { id: requestId },\n        failedResponseHandler: createStatusCodeErrorResponseHandler(),\n        successfulResponseHandler: createJsonResponseHandler(\n          asyncPollResponseSchema,\n        ),\n        abortSignal,\n        fetch: this.config.fetch,\n      });\n\n      const status = pollResponse.status;\n\n      if (status === 'Ready') {\n        const imageUrl = pollResponse.result?.sample;\n        if (typeof imageUrl === 'string') {\n          return imageUrl;\n        }\n        throw new Error(\n          'Fireworks poll response is Ready but missing result.sample',\n        );\n      }\n\n      if (status === 'Error' || status === 'Failed') {\n        throw new Error(\n          `Fireworks image generation failed with status: ${status}`,\n        );\n      }\n\n      // Wait before next poll attempt\n      await delay(pollIntervalMillis);\n    }\n\n    throw new Error(\n      `Fireworks image generation timed out after ${pollTimeoutMillis}ms`,\n    );\n  }","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/fireworks/src/fireworks-image-model.ts#L349-L385","documentation":"The Fireworks image model polls an image generation request until its status is 'Ready'. When status is Ready but `result.sample` (the generated image URL) is absent or not a string, it throws a plain Error indicating the response is inconsistent. This guards against a malformed Fireworks polling response.","triggerScenarios":"Calling `fireworks.image(...).doGenerate` where a poll request returns `status: 'Ready'` but the body lacks `result.sample` — Fireworks API contract change, truncated response, or proxy interference.","commonSituations":"Outdated @ai-sdk/fireworks against an updated Fireworks REST API; corporate proxy or gateway rewriting JSON; rare Fireworks-side inconsistency between status and result payload.","solutions":["Upgrade @ai-sdk/fireworks to the latest version","Retry the image generation request","Inspect the raw poll response payload to confirm the `result` shape","Check Fireworks status/announcements for API changes"],"exampleFix":"// before\npnpm add @ai-sdk/fireworks@1.0.0\n// after\npnpm add @ai-sdk/fireworks@latest","handlingStrategy":"retry","validationCode":"// guard raw poll responses when reading them directly\nfunction pollHasSample(r: unknown): r is { status: string; result: { sample: string } } {\n  return typeof r === 'object' && r !== null && typeof (r as any).result?.sample === 'string';\n}","typeGuard":"function isMissingSampleError(e: unknown): boolean {\n  return e instanceof Error && e.message.includes('missing result.sample');\n}","tryCatchPattern":"try {\n  return await generateImage({ model: fireworks.image(modelId), prompt });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('missing result.sample')) {\n    return retry(() => generateImage({ model: fireworks.image(modelId), prompt }));\n  }\n  throw e;\n}","preventionTips":["Keep @ai-sdk/fireworks updated with the Fireworks REST API contract","Retry image generation once on malformed poll responses before failing hard","Verify through Fireworks' own tooling that the request actually produced output","Watch for proxies/gateways altering JSON bodies"],"tags":["api-response","image-generation","polling","fireworks"],"backgroundTag":"malformed-api-response","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}