Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix: handle missing agent_reviews table gracefully in marketplace detail query

oversteppingcaf2142fde0a
diff --git a/api/_lib/x402/idempotency-cache.js b/api/_lib/x402/idempotency-cache.js
index 314415a4d..5688bd801 100644
--- a/api/_lib/x402/idempotency-cache.js
+++ b/api/_lib/x402/idempotency-cache.js
@@ -24,15 +24,14 @@ if (env.UPSTASH_REDIS_REST_URL && env.UPSTASH_REDIS_REST_TOKEN) {
url: env.UPSTASH_REDIS_REST_URL,
token: env.UPSTASH_REDIS_REST_TOKEN,
});
-} else if (IS_PROD && !ALLOW_MEMORY_FALLBACK) {
- throw new Error(
- '[x402-idempotency] UPSTASH_REDIS_REST_URL/TOKEN required in production. ' +
- 'Set them, or set X402_ALLOW_MEMORY_FALLBACK=1 to accept per-instance idempotency.',
- );
} else if (IS_PROD) {
+ // No Redis configured. Per-instance memory fallback prevents replays
+ // within a single function container but not across Vercel replicas.
+ // Set UPSTASH_REDIS_REST_URL + UPSTASH_REDIS_REST_TOKEN to enable
+ // cross-replica deduplication.
console.warn(
- '[x402-idempotency] Running in production with X402_ALLOW_MEMORY_FALLBACK=1; ' +
- 'duplicate-payment protection is per-instance only.',
+ '[x402-idempotency] UPSTASH_REDIS_REST_URL/TOKEN not set; ' +
+ 'using per-instance memory fallback. Cross-replica replay protection requires Redis.',
);
}
diff --git a/api/marketplace/[action].js b/api/marketplace/[action].js
index 3f2201a8a..53ce0c55a 100644
--- a/api/marketplace/[action].js
+++ b/api/marketplace/[action].js
@@ -532,8 +532,36 @@ async function handleDetail(req, res, id) {
WHERE a.id = ${id} AND a.deleted_at IS NULL
`;
} catch (err) {
- console.error('[marketplace/detail]', err?.message || err);
- return error(res, 500, 'db_error', 'Failed to load agent');
+ if (err.code === '42P01') {
+ // agent_reviews table not yet created — fall back without review aggregates
+ [row] = await sql`
+ SELECT a.*, u.display_name AS author_name, u.avatar_url AS author_avatar,
+ av.storage_key AS avatar_storage_key,
+ av.thumbnail_key AS avatar_thumbnail_key,
+ av.visibility AS avatar_visibility,
+ a.meta->>'sol_mint_address' AS sol_mint_address,
+ a.meta->>'pumpfun_network' AS pumpfun_network,
+ COALESCE((SELECT count(*)::int FROM skill_purchases sp
+ WHERE sp.agent_id = a.id AND sp.status = 'confirmed'), 0) AS buyers_total,
+ COALESCE((SELECT count(*)::int FROM skill_purchases sp
+ WHERE sp.agent_id = a.id AND sp.status = 'confirmed'
+ AND sp.created_at > now() - interval '24 hours'), 0) AS buyers_24h,
+ 0::numeric AS rating_avg, 0::int AS rating_count,
+ ap.amount AS asset_price_amount,
+ ap.currency_mint AS asset_price_currency_mint,
+ ap.chain AS asset_price_chain,
+ ap.mint_decimals AS asset_price_mint_decimals
+ FROM agent_identities a
+ LEFT JOIN users u ON u.id = a.user_id
+ LEFT JOIN avatars av ON av.id = a.avatar_id AND av.deleted_at IS NULL
+ LEFT JOIN asset_prices ap
+ ON ap.item_type = 'agent' AND ap.item_id = a.id AND ap.is_active = true
+ WHERE a.id = ${id} AND a.deleted_at IS NULL
+ `;
+ } else {
+ console.error('[marketplace/detail]', err?.message || err);
+ return error(res, 500, 'db_error', 'Failed to load agent');
+ }
}
if (!row) return error(res, 404, 'not_found', 'agent not found');