Significant-Gravitas/AutoGPT · error · DatabaseError

Failed to fetch my agents

Error message

Failed to fetch my agents

What it means

A generic DatabaseError raised at the end of get_my_agents() in the store DB layer. It wraps ANY unexpected exception (Prisma query failure, connection drop, bad pagination args, data shape mismatch) that occurs while listing the authenticated user's unpublished agents, so the original cause is only visible in the server log line 'Error getting my agents: {e}'.

Source

Thrown at autogpt_platform/backend/backend/api/features/store/db.py:1392

                agent_image=library_agent.imageUrl,
                recommended_schedule_cron=graph.recommendedScheduleCron,
            )
            for library_agent in library_agents
            if (graph := library_agent.AgentGraph)
        ]

        return store_model.MyUnpublishedAgentsResponse(
            agents=my_agents,
            pagination=store_model.Pagination(
                current_page=page,
                total_items=total,
                total_pages=total_pages,
                page_size=page_size,
            ),
        )
    except Exception as e:
        logger.error(f"Error getting my agents: {e}")
        raise DatabaseError("Failed to fetch my agents") from e


async def get_agent(store_listing_version_id: str) -> GraphModel:
    """Get agent using the version ID and store listing version ID."""
    slv = await prisma.models.StoreListingVersion.prisma().find_unique(
        where={"id": store_listing_version_id}
    )

    if not slv:
        raise NotFoundError(
            f"Store listing version {store_listing_version_id} not found"
        )

    graph = await get_graph(
        graph_id=slv.agentGraphId,
        version=slv.agentGraphVersion,
        user_id=None,
        for_export=True,

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Read the server log for the 'Error getting my agents: {e}' line — the wrapped exception is the real cause; fix that first.
  2. Verify Postgres is up: `docker compose up -d` (backend stack).
  3. Regenerate the Prisma client and apply migrations: `poetry run prisma generate && poetry run prisma migrate dev`.
  4. If the inner error is a DataError about a column/field, confirm the deployed schema matches schema.prisma for StoreListing/StoreListingVersion and User.
Defensive patterns

Strategy: try-catch

Try / catch

from backend.util.exceptions import DatabaseError

try:
    resp = await store_db.get_my_agents(user_id=uid, page=page, page_size=size)
except DatabaseError as e:
    logger.error(f"my_agents failed: {e}")
    raise HTTPException(status_code=503, detail="Store temporarily unavailable") from e

Prevention

When it happens

Trigger: GET /store/my_agents (authenticated) when the underlying Prisma count/find_many queries against StoreListing/StoreListingVersion fail: Postgres unreachable, migration drift between schema.prisma and the live DB, a null field breaking model construction, or an invalid page/page_size causing a Prisma error.

Common situations: Local dev without `docker compose up -d` postgres running, prisma client not regenerated after a schema change (`poetry run prisma generate`), stale DB needing `poetry run prisma migrate dev`, or a production DB outage/failover during the request.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/f747b02500fb8d25. Report an issue: GitHub.