{"record":{"id":"a2f831f132021b1d","repo":"Significant-Gravitas/AutoGPT","slug":"image-generation-failed-str-e","errorCode":null,"errorMessage":"Image generation failed: {str(e)}","messagePattern":"Image generation failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/image_gen.py","lineNumber":178,"sourceCode":"            elif isinstance(output, FileOutput):\n                image_bytes = output.read()\n            elif isinstance(output, str):\n                # Output is a URL\n                response = await Requests().get(output)\n                image_bytes = response.content\n            else:\n                raise RuntimeError(\"Unexpected output format from the model.\")\n\n            return io.BytesIO(image_bytes)\n\n        except ReplicateError as e:\n            if e.status == 401:\n                raise RuntimeError(\"Invalid Replicate API token\") from e\n            raise RuntimeError(f\"Replicate API error: {str(e)}\") from e\n\n    except Exception as e:\n        logger.exception(\"Failed to generate agent image\")\n        raise RuntimeError(f\"Image generation failed: {str(e)}\")\n","sourceCodeStart":160,"sourceCodeEnd":179,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/image_gen.py#L160-L179","documentation":"Outer catch-all RuntimeError in generate_agent_image_v1(): every exception that is not the specifically-handled ReplicateError branch — network failures to replicate.com, timeouts fetching the output URL, the inner ValueErrors/RuntimesErrors about output shape — is logged ('Failed to generate agent image') and re-raised as 'Image generation failed: {str(e)}'. The original cause is in the logged traceback and the appended message.","triggerScenarios":"Any agent-image request where an unexpected failure occurs: DNS/proxy blocking api.replicate.com, the Requests().get(output_url) download failing, client library exceptions, or one of the inner errors (missing key, unexpected output, 401) bubbling into this handler.","commonSituations":"Egress-restricted deployments without allow-listed replicate.com and its output CDN; transient network blips; the inner error strings ('Missing Replicate API key...', 'Unexpected output format...') appearing wrapped in this message.","solutions":["Read the appended {str(e)} — it usually names the real problem (missing key, 401, unexpected format) which each have their own fix.","Check the server traceback logged via logger.exception for the failing call site.","If network-related, allow-list api.replicate.com and the output host (replicate.delivery/CDN) in egress rules.","Retry once for transient network errors before surfacing failure to the user."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        image = await generate_agent_image_v1(agent)\n        break\n    except RuntimeError as e:\n        msg = str(e)\n        if attempt == 0 and not any(\n            k in msg for k in (\"API key\", \"token\", \"output format\")\n        ):\n            continue  # transient network only\n        raise","preventionTips":["Allow-list api.replicate.com and its delivery CDN in egress-restricted environments.","Don't retry on deterministic causes (missing key, 401, bad output format) — only on network errors."],"tags":["store","replicate","image-generation","network","wrapper-error"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}