{"record":{"id":"e7c455132d73299e","repo":"ATH-MaaS/Pixelle-Video","slug":"str-e-e7c455","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/image.py","lineNumber":69,"sourceCode":"            workflow=request.workflow\n        )\n        \n        # For backward compatibility, only support image results in /image endpoint\n        if media_result.is_video:\n            raise HTTPException(\n                status_code=400,\n                detail=\"Video workflow used. Please use /media/generate endpoint for video generation.\"\n            )\n        \n        return ImageGenerateResponse(\n            image_path=media_result.url\n        )\n        \n    except HTTPException:\n        raise\n    except Exception as e:\n        logger.error(f\"Image generation error: {e}\")\n        raise HTTPException(status_code=500, detail=str(e))\n\n","sourceCodeStart":51,"sourceCodeEnd":71,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/api/routers/image.py#L51-L71","documentation":"The /image/generate endpoint wraps image generation in a broad except Exception and re-raises any unexpected failure as HTTP 500 with str(e) as the detail. HTTPExceptions (like the video-workflow 400 above) are re-raised unchanged. This 500 means the generation pipeline itself failed — workflow lookup, execution, or result handling — with the internal error text exposed to the client.","triggerScenarios":"POST /image/generate where the underlying media service call throws: ComfyUI/workflow engine unreachable, workflow JSON invalid, model missing, timeout, or unexpected response shape from media generation.","commonSituations":"Backend ComfyUI service down or restarting; workflow file removed or renamed after a version upgrade; GPU OOM during inference; network timeout between API and generation backend.","solutions":["Check server logs for 'Image generation error:' to identify the root cause","Verify the generation backend (e.g. ComfyUI) is running and reachable","Confirm the requested workflow exists and is an image workflow","Retry the request if the failure was a transient timeout","Server-side: return a generic detail instead of str(e) and log the stack trace"],"exampleFix":"// before\nexcept Exception as e:\n    logger.error(f\"Image generation error: {e}\")\n    raise HTTPException(status_code=500, detail=str(e))\n// after\nexcept Exception:\n    logger.exception(\"Image generation error\")\n    raise HTTPException(status_code=500, detail=\"Image generation failed; see server logs\")","handlingStrategy":"try-catch","validationCode":"// verify backend health and workflow validity before generating\nconst health = await fetch(`${base}/health`).then(r => r.ok);\nconst workflows = (await fetch(`${base}/workflows/image`).then(r => r.json())).workflows;\nif (!health || !workflows.some(w => w.id === request.workflow)) throw new Error('Backend down or unknown workflow');","typeGuard":"function isImageResult(m) { return m != null && typeof m === 'object' && m.is_video === false && typeof m.url === 'string'; }","tryCatchPattern":"try {\n  const res = await fetch('/image/generate', {method:'POST', body: JSON.stringify(req)});\n  if (!res.ok) throw Object.assign(new Error((await res.json().catch(()=>({}))).detail ?? 'generation failed'), {status: res.status});\n  return await res.json();\n} catch (err) {\n  if (err.status >= 500 && attempts < 3) return retryWithBackoff();\n  throw err;\n}","preventionTips":["Check the media backend health endpoint before batch generation","Validate workflow names against GET /workflows/image","Use exponential backoff for 500s that stem from transient backend timeouts","Report the server-side 'Image generation error' log line when filing bugs"],"tags":["http-500","image-generation","fastapi","backend-failure"],"backgroundTag":"internal-server-error-500","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}