{"record":{"id":"628e9a80267c17e3","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-fetch-agent-details","errorCode":null,"errorMessage":"Failed to fetch agent details","messagePattern":"Failed to fetch agent details","errorType":"exception","errorClass":"DatabaseError","httpStatus":500,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":345,"sourceCode":"            )\n            changelog_data = [\n                store_model.ChangelogEntry(\n                    version=str(version.version),\n                    changes_summary=version.changesSummary or \"No changes recorded\",\n                    date=version.createdAt,\n                )\n                for version in changelog_versions\n            ]\n\n        logger.debug(f\"Found agent details for {username}/{agent_name}\")\n        details = store_model.StoreAgentDetails.from_db(agent)\n        details.changelog = changelog_data\n        return details\n    except NotFoundError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error getting store agent details: {e}\")\n        raise DatabaseError(\"Failed to fetch agent details\") from e\n\n\n@overload\nasync def get_available_graph(\n    store_listing_version_id: str, hide_nodes: Literal[False]\n) -> GraphModel: ...\n\n\n@overload\nasync def get_available_graph(\n    store_listing_version_id: str, hide_nodes: Literal[True] = True\n) -> GraphModelWithoutNodes: ...\n\n\nasync def get_available_graph(\n    store_listing_version_id: str,\n    hide_nodes: bool = True,\n) -> GraphModelWithoutNodes | GraphModel:","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L327-L363","documentation":"DatabaseError raised by get_store_agent_details when the agent row was found but a later step failed — changelog fetching, StoreAgentDetails.from_db conversion, or serialization — or the initial Prisma query itself errored. NotFoundError is re-raised untouched; everything else is wrapped with this generic message and chained cause.","triggerScenarios":"Loading public agent details while the changelog query (StoreListingVersion find_many) fails, the DB drops mid-request, or the row contains data from_db cannot map (null in a required field after a schema/partial migration).","commonSituations":"Schema drift where old rows lack newly required columns; DB connection flakiness; Prisma client out of sync with the view definition; changelog rows with unexpected shapes.","solutions":["Inspect logs for 'Error getting agent details' to see the chained root cause.","If schema-related, run pending migrations and regenerate the Prisma client.","Data-repair: backfill or fix rows that violate the model's expectations (e.g. null required fields).","Retry once on transient DB errors; escalate if persistent."],"exampleFix":"# before\n# migration added NOT NULL column without default; old rows break from_db\n# after\nALTER TABLE ... ADD COLUMN ... DEFAULT ...;  -- then regenerate prisma client","handlingStrategy":"try-catch","validationCode":"// Callers can't pre-validate DB state; validate only inputs\nif (!username || !agent_name) throw new TypeError('username and slug required');","typeGuard":"function isDatabaseError(e: unknown): e is DatabaseError {\n  return e instanceof Error && e.message === 'Failed to fetch agent details';\n}","tryCatchPattern":"try { return await getStoreAgentDetails(u, slug); }\ncatch (e) {\n  if (isNotFound(e)) return null;\n  if (isDatabaseError(e)) { logger.error(e.cause); return retryOnce(getStoreAgentDetails, u, slug); }\n  throw e;\n}","preventionTips":["Always inspect the chained cause (e.__cause__) — the message alone is generic.","Backfill required columns when adding NOT NULL fields to existing tables.","Exclude changelog (include_changelog=false) to narrow down failure origin when debugging."],"tags":["database","prisma","store","changelog"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}