{"record":{"id":"e537f5e9e48d43c0","repo":"chatboxai/chatbox","slug":"the-image-record-linked-to-this-approved-tool-call","errorCode":null,"errorMessage":"The image record linked to this approved tool call no longer exists. Start a new request and ask the user to approve it again.","messagePattern":"The image record linked to this approved tool call no longer exists\\. Start a new request and ask the user to approve it again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/packages/chatbox-cli/images.ts","lineNumber":235,"sourceCode":"    modelId ??= selected?.modelId\n  }\n  if (!provider) throw new ChatboxCliUsageError('Missing --provider (or configure a Chatbox license).')\n  if (!modelId) throw new ChatboxCliUsageError('Missing --model.')\n  const signature = JSON.stringify({ prompt, provider, modelId, count, aspectRatio, dalleStyle })\n  if (existing) {\n    if (existing.signature !== signature) {\n      throw new Error(`Tool call ${cacheKey} was reused with different image arguments.`)\n    }\n    return existing.promise\n  }\n\n  if (persistedExecutionValue !== null) {\n    if (persistedExecutionValue.signature !== signature) {\n      throw new Error(`Tool call ${cacheKey} was reused with different image arguments.`)\n    }\n    const persistedRecord = await platform.getImageGenerationStorage().getById(persistedExecutionValue.recordId)\n    if (!persistedRecord) {\n      throw new Error(\n        'The image record linked to this approved tool call no longer exists. Start a new request and ask the user to approve it again.'\n      )\n    }\n    return restoredExecutionResult(persistedRecord)\n  }\n\n  if (settings.providers?.[provider]?.excludedModels?.includes(modelId)) {\n    throw new ChatboxCliUsageError(`Image model is disabled in settings: ${provider}/${modelId}`)\n  }\n  availableModels ??= await getAvailableImageModels(settings)\n  if (!availableModels.some((model) => model.provider === provider && model.modelId === modelId)) {\n    throw new ChatboxCliUsageError(\n      `Image model is not available: ${provider}/${modelId}. Use \"chatbox image models\" to list available models.`\n    )\n  }\n\n  if (!approvedRequest) {\n    const licenseDetail = settings.licenseDetail","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/chatbox-cli/images.ts#L217-L253","documentation":"Plain Error thrown when a persisted execution exists for the approved tool-call (persistedExecutionValue) but platform.getImageGenerationStorage().getById(recordId) returns null. The image record that approval was bound to has been deleted, so the approval cannot be honored and the user must approve a fresh request.","triggerScenarios":"The image-generation record was deleted (user cleared history, storage eviction, account reset) between approval and the replay/restore attempt; or a storage migration dropped the record.","commonSituations":"Re-running an approved tool-call after the user purged image history, cross-session restore after local-storage cleanup, or a bug that removed records out of band.","solutions":["Start a brand-new image request and ask the user to approve it again.","Do not attempt to restore/replay a tool-call whose record may have been deleted; treat this error as terminal.","If records are disappearing unexpectedly, audit image-generation storage retention/eviction settings."],"exampleFix":"// before: replaying an approved tool-call after history purge\nawait generateImage(ctx) // throws\n\n// after: start fresh\nawait requestAppActionApproval(newToolCallId, 'image.generate', ...)\nawait generateImage({ ...ctx, toolCallId: newToolCallId })","handlingStrategy":"try-catch","validationCode":"// Best effort: confirm the record still exists before replaying an approved call.\nconst record = await platform.getImageGenerationStorage().getById(persistedExecutionValue.recordId)\nif (!record) {\n  // start a fresh request and re-request approval instead of replaying\n}","typeGuard":null,"tryCatchPattern":"try {\n  await generateImage(ctx)\n} catch (error) {\n  if (error instanceof Error && error.message.includes('no longer exists')) {\n    // terminal: start a new request and ask the user to approve again\n  } else throw error\n}","preventionTips":["Do not attempt to restore/replay a tool-call whose record may have been deleted.","Treat history purges as invalidating prior image approvals.","Audit storage retention/eviction if records vanish unexpectedly."],"tags":["chatbox-cli","image-generation","approval","data-not-found","storage"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}