Significant-Gravitas/AutoGPT · error · DatabaseError
Failed to create store review
Error message
Failed to create store review
What it means
Generic wrapper around create_store_review: any prisma.errors.PrismaError during the review upsert becomes this DatabaseError. The upsert targets a StoreListingReview keyed by user + listing version; the most common underlying cause is a P2003 foreign-key violation because store_listing_version_id does not exist (reviewing a version that was deleted or never published), or a not-null/constraint failure on score.
Source
Thrown at autogpt_platform/backend/backend/api/features/store/db.py:1185
)
review = await prisma.models.StoreListingReview.prisma().upsert(
where={
"storeListingVersionId_reviewByUserId": {
"storeListingVersionId": store_listing_version_id,
"reviewByUserId": user_id,
}
},
data=data,
)
return store_model.StoreReview(
score=review.score,
comments=review.comments,
)
except prisma.errors.PrismaError as e:
logger.error(f"Database error creating store review: {e}")
raise DatabaseError("Failed to create store review") from e
async def get_user_profile(
user_id: str,
) -> store_model.ProfileDetails | None:
logger.debug(f"Getting user profile for {user_id}")
try:
profile = await prisma.models.Profile.prisma().find_first(
where={"userId": user_id}
)
if not profile:
return None
return store_model.ProfileDetails.from_db(profile)
except Exception as e:
logger.error(f"Error getting user profile: {e}")
raise DatabaseError("Failed to get user profile") from eView on GitHub (pinned to 9c8bb5550f)
Solutions
- Verify the listing version exists: GET the store agent details and resubmit with its current store_listing_version_id.
- Check logs for the PrismaError code (P2003 = FK, P2002 = duplicate) to confirm.
- For robustness, offer the review against the listing's current version rather than a pinned one.
Example fix
// before
await api.createReview(oldVersionId, { score: 5 });
// after
const details = await api.getStoreAgent(slug);
await api.createReview(details.store_listing_version_id, { score: 5 }); Defensive patterns
Strategy: validation
Validate before calling
const details = await api.getStoreAgent(slug);
const versionId = details.store_listing_version_id; // always the live version
await api.createReview(versionId, { score, comments }); Try / catch
from backend.util.exceptions import DatabaseError
try:
await store_db.create_store_review(user_id, version_id, score, comments)
except DatabaseError as e:
if getattr(e.__cause__, 'code', None) == 'P2003':
ui.show('This listing version is no longer available — reload the page');
else:
raise Prevention
- Resolve the current store_listing_version_id from the listing details at review time.
- Treat deep links to old listing versions as fresh navigations that refetch state.
- Check the chained PrismaError code before deciding to retry vs reload.
When it happens
Trigger: POST a review for a store_listing_version_id from a stale page after the listing was updated to a new version and the old version row removed; review submitted from a different environment (staging ID against prod); score outside the column's constraint.
Common situations: Store page open in a tab while the creator publishes a new version; deep links to old listing versions; browser back-forward to a cached review form.
Related errors
- Failed to fetch store agents
- Failed to fetch agent details
- Failed to fetch agent
- StoreListing {listing.id} has no CreatorProfile — FK violate
- Failed to fetch store creators
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/e89943579a66706e.
Report an issue: GitHub.