{"record":{"id":"555e66887a93c8b6","repo":"invoke-ai/InvokeAI","slug":"image-body-image-name-not-found","errorCode":null,"errorMessage":"Image '{body.image_name}' not found","messagePattern":"Image '(.+?)' not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"invokeai/app/api/routers/utilities.py","lineNumber":324,"sourceCode":"        prompt = await asyncio.to_thread(\n            _run_image_to_prompt,\n            body.image_name,\n            body.model_key,\n            body.instruction,\n            body.task_id,\n            current_user.user_id,\n        )\n        if body.task_id is not None:\n            events.emit_llm_task_complete(task_id=body.task_id, user_id=current_user.user_id)\n        return ImageToPromptResponse(prompt=prompt)\n    except UnknownModelException:\n        if body.task_id is not None:\n            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error=\"Model not found\")\n        raise HTTPException(status_code=404, detail=f\"Model '{body.model_key}' not found\")\n    except ImageFileNotFoundException:\n        if body.task_id is not None:\n            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error=\"Image not found\")\n        raise HTTPException(status_code=404, detail=f\"Image '{body.image_name}' not found\")\n    except (ValueError, TypeError) as e:\n        if body.task_id is not None:\n            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error=str(e))\n        raise HTTPException(status_code=422, detail=str(e))\n    except Exception as e:\n        if body.task_id is not None:\n            events.emit_llm_task_error(task_id=body.task_id, user_id=current_user.user_id, error=str(e))\n        logger.error(f\"Error generating prompt from image: {e}\")\n        raise HTTPException(status_code=500, detail=str(e))\n","sourceCodeStart":306,"sourceCodeEnd":334,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/utilities.py#L306-L334","documentation":"The image_to_prompt endpoint catches ImageFileNotFoundException raised while fetching body.image_name from InvokeAI's image store and converts it into HTTP 404 with detail \"Image '{body.image_name}' not found\". The image record or its underlying file does not exist.","triggerScenarios":"POST /utilities/image_to_prompt with an image_name that was deleted, purged from disk (deleted files setting), never existed, or belongs to another user/board the caller cannot see.","commonSituations":"Client kept a reference after the image was deleted via the UI; gallery cleaned up old images; name typo or wrong image-UUID format in an automation script; multiuser install where the image belongs to a different account.","solutions":["Verify the image exists via GET /api/v1/images/{image_name} before calling image_to_prompt","Re-upload or regenerate the image if it was deleted/purged","Correct the image_name in the calling script (copy the exact UUID name from the gallery API)","Check that the images directory on disk still contains the file if the record exists"],"exampleFix":"# before\nresp = requests.post(url, json={\"image_name\": deleted_name, \"model_key\": key})\n# after\nif requests.get(f\"{base}/api/v1/images/{image_name}\").status_code == 200:\n    resp = requests.post(url, json={\"image_name\": image_name, \"model_key\": key})","handlingStrategy":"validation","validationCode":"r = requests.get(f\"{base}/api/v1/images/{image_name}\")\nassert r.status_code == 200, f\"image {image_name} missing\"","typeGuard":null,"tryCatchPattern":"try:\n    resp = requests.post(f\"{base}/utilities/image_to_prompt\", json={\"image_name\": img, \"model_key\": key})\n    resp.raise_for_status()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 404 and \"Image\" in e.response.text:\n        reupload_or_pick_new_image()","preventionTips":["Check image existence via the images API before captioning","Handle deleted-files cleanup policies when caching image names","Use exact UUID names returned by the API, never hand-typed ids"],"tags":["http-404","image-not-found","api"],"backgroundTag":"resource-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}