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(bazaar): keep a stray ? or a huge price cap from 500ing discovery

nirholasd228a822909c
diff --git a/api/_lib/x402/bazaar-client.js b/api/_lib/x402/bazaar-client.js
index 7b56c5fc1..99ebaf078 100644
--- a/api/_lib/x402/bazaar-client.js
+++ b/api/_lib/x402/bazaar-client.js
@@ -434,8 +434,13 @@ export function filterByNetwork(items, pattern) {
function patternToRegex(pattern) {
if (pattern instanceof RegExp) return pattern;
// support wildcards like "eip155:*" or "solana:*"
+ // `*` is the ONLY wildcard; every other regex metacharacter is escaped to a
+ // literal. `?` used to be left unescaped, so a user-supplied `network=?`
+ // compiled to /^?$/ and threw "Nothing to repeat", 500ing /api/bazaar/list,
+ // /api/bazaar/search, /api/agora and the bazaar MCP discovery tools. A
+ // pattern that matches no network must return no items, not an error.
const escaped = String(pattern)
- .replace(/[.+^${}()|[\]\\]/g, '\\$&')
+ .replace(/[.+?^${}()|[\]\\]/g, '\\$&')
.replace(/\*/g, '.*');
return new RegExp(`^${escaped}$`, 'i');
}
diff --git a/api/_mcpbazaar/tools.js b/api/_mcpbazaar/tools.js
index 14204a336..e8e26099e 100644
--- a/api/_mcpbazaar/tools.js
+++ b/api/_mcpbazaar/tools.js
@@ -28,10 +28,18 @@ async function enforce(auth) {
}
}
-// USDC and most x402 stablecoins use 6 decimals — convert a human dollar cap to
-// the atomic units filterByMaxPrice compares against.
+// USDC and most x402 stablecoins use 6 decimals, so convert a human dollar cap
+// to the atomic units filterByMaxPrice compares against. Returns null when the
+// cap is effectively unbounded (a number so large the conversion overflows),
+// telling the caller to skip the filter rather than reject the whole query.
function usdcToAtomic(usd) {
- return String(Math.round(Number(usd) * 1_000_000));
+ const atomic = Math.round(Number(usd) * 1_000_000);
+ if (!Number.isFinite(atomic)) return null;
+ if (atomic <= 0) return '0';
+ // String(1e21) is "1e+21", which parseAtomicAmount rejects as non-integer and
+ // filterByMaxPrice then throws on. BigInt renders full digits at any
+ // magnitude, so a large cap filters instead of failing the tool call.
+ return BigInt(atomic).toString();
}
// Project a normalized bazaar item down to the fields a client actually needs,
@@ -55,7 +63,10 @@ function slim(it) {
function applyFilters(resources, { network, max_price_usdc }) {
let out = resources;
if (network) out = filterByNetwork(out, network);
- if (max_price_usdc != null) out = filterByMaxPrice(out, usdcToAtomic(max_price_usdc));
+ if (max_price_usdc != null) {
+ const cap = usdcToAtomic(max_price_usdc);
+ if (cap !== null) out = filterByMaxPrice(out, cap);
+ }
return out;
}