{"record":{"id":"c76b6d255374c534","repo":"chatboxai/chatbox","slug":"the-image-request-changed-after-approval-ask-the","errorCode":null,"errorMessage":"The image request changed after approval. Ask the user to review it again.","messagePattern":"The image request changed after approval\\. Ask the user to review it again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/packages/chatbox-cli/images.ts","lineNumber":184,"sourceCode":"  const requestedAspectRatio = stringFlag(context.parsed, 'aspect-ratio')\n  const requestedStyle = stringFlag(context.parsed, 'style')\n  if (requestedStyle && requestedStyle !== 'vivid' && requestedStyle !== 'natural') {\n    throw new ChatboxCliUsageError('--style must be vivid or natural.')\n  }\n  const parsedStyle: 'vivid' | 'natural' | undefined =\n    requestedStyle === 'vivid' || requestedStyle === 'natural' ? requestedStyle : undefined\n  const approvedRequest =\n    context.approved && context.approvalDetails?.type === 'image_generation' ? context.approvalDetails : undefined\n  if (\n    approvedRequest &&\n    (approvedRequest.prompt !== requestedPrompt ||\n      approvedRequest.count !== requestedCount ||\n      approvedRequest.aspectRatio !== requestedAspectRatio ||\n      approvedRequest.style !== parsedStyle ||\n      (requestedProvider !== undefined && approvedRequest.provider !== requestedProvider) ||\n      (requestedModelId !== undefined && approvedRequest.modelId !== requestedModelId))\n  ) {\n    throw new Error('The image request changed after approval. Ask the user to review it again.')\n  }\n\n  const prompt = approvedRequest?.prompt ?? requestedPrompt\n  const count = approvedRequest?.count ?? requestedCount\n  const aspectRatio = approvedRequest?.aspectRatio ?? requestedAspectRatio\n  const dalleStyle = approvedRequest?.style ?? parsedStyle\n\n  const cacheKey = `${sessionId}:${toolCallId}`\n  const persistedExecutionKey = imageExecutionStorageKey(sessionId, toolCallId)\n  const existing = executionCache.get(cacheKey)\n  const persistedExecutionValue = existing ? null : await storage.getItem<unknown>(persistedExecutionKey, null)\n  if (persistedExecutionValue !== null && !isPersistedImageExecution(persistedExecutionValue)) {\n    throw new Error(`Stored image execution metadata is invalid for tool call ${cacheKey}.`)\n  }\n  const boundSignature = existing?.signature ?? persistedExecutionValue?.signature\n  const boundRequest = boundSignature ? parseImageExecutionSignature(boundSignature) : undefined\n  if (boundSignature && !boundRequest) {\n    throw new Error(`Stored image execution signature is invalid for tool call ${cacheKey}.`)","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/chatbox-cli/images.ts#L166-L202","documentation":"Plain Error (not a usage error) thrown when an approved image-generation request exists but one of its fields (prompt, count, aspectRatio, style, provider when specified, modelId when specified) differs from the current request. The approval is bound to an exact signature; changing any signed field invalidates it and forces re-approval to prevent billing the user for something they did not see.","triggerScenarios":"User approved a request, then the prompt/count/aspect-ratio/style/provider/model changed before execution; or an LLM reused the approved tool-call id with tweaked arguments.","commonSituations":"An agent editing the prompt after the approval card, a retry that altered parameters, or stale approval details reused across turns.","solutions":["Keep the request fields identical between approval and execution; do not mutate them after the user approves.","If parameters must change, start a fresh request and request approval again rather than reusing the tool-call id.","Treat this error as terminal for the current tool-call and re-prompt the user for fresh approval."],"exampleFix":"// before: agent tweaks prompt after approval\napprovedDetails.prompt = newPrompt\nawait generateImage(ctx)\n\n// after: start a new approved request instead\nawait requestAppActionApproval(newToolCallId, 'image.generate', ...)\n// then dispatch with the new tool-call id and identical fields","handlingStrategy":"validation","validationCode":"// Ensure the executed request matches the approved signature exactly.\nfunction matchesApproval(req: ImageRequest, apv: ImageRequest): boolean {\n  return (\n    req.prompt === apv.prompt &&\n    req.count === apv.count &&\n    req.aspectRatio === apv.aspectRatio &&\n    req.style === apv.style &&\n    (req.provider === undefined || req.provider === apv.provider) &&\n    (req.modelId === undefined || req.modelId === apv.modelId)\n  )\n}\nif (approved && !matchesApproval(currentRequest, approvedRequest)) {\n  // start a fresh approval flow instead of reusing the tool-call id\n}","typeGuard":null,"tryCatchPattern":"try {\n  await generateImage(ctx)\n} catch (error) {\n  if (error instanceof Error && error.message.includes('changed after approval')) {\n    // terminal: re-request approval with the new parameters; do not retry as-is\n  } else throw error\n}","preventionTips":["Never mutate request fields after the user approves.","If parameters must change, start a new request and re-approve rather than reusing the tool-call id.","Treat this error as terminal for the current tool-call."],"tags":["chatbox-cli","image-generation","approval","security","billing"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}