DIYgod/RSSHub · error · Error
Event not found
Error message
Event not found
What it means
Plain Error thrown by the Polymarket event handler when ofetch returns a falsy event body from GAMMA_API /events/slug/{slug}. It guards the case where the Gamma API responds successfully with null/empty for a slug that does not match a known event. (A hard HTTP error from ofetch would already have thrown before this line.)
Source
Thrown at lib/routes/polymarket/event.ts:42
radar: [
{
source: ['polymarket.com/event/:slug'],
target: '/event/:slug',
},
],
name: 'Event',
url: 'polymarket.com',
maintainers: ['heqi201255'],
handler,
};
async function handler(ctx) {
const slug = ctx.req.param('slug');
const event = await ofetch<Event>(`${GAMMA_API}/events/slug/${slug}`);
if (!event) {
throw new Error('Event not found');
}
const items = event.markets!.map((market) => ({
title: market.question,
description: `
<p><strong>Odds:</strong> ${formatOddsDisplay(market)}</p>
<p><strong>Volume:</strong> $${Number(market.volume || 0).toLocaleString()}</p>
${market.oneDayPriceChange ? `<p><strong>24h Change:</strong> ${(market.oneDayPriceChange * 100).toFixed(1)}%</p>` : ''}
${market.image ? `<img src="${market.image}" alt="${market.question}" style="max-width: 100%;">` : ''}
`,
link: `https://polymarket.com/event/${event.slug}`,
pubDate: market.startDate || event.startDate ? parseDate(market.startDate || event.startDate!) : undefined,
category: event.tags?.map((t) => t.label).filter(Boolean) as string[],
}));
return {
title: event.title,
link: `https://polymarket.com/event/${event.slug}`,View on GitHub (pinned to bed535e087)
Solutions
- Open https://polymarket.com/event/{slug} to confirm the event exists and the slug is current.
- Copy the slug exactly from the current Polymarket URL path.
- Strip whitespace/slashes from the slug before subscribing.
- If the event moved into a series, use the /polymarket/series/:slug route instead.
Defensive patterns
Strategy: validation
Validate before calling
function isValidPolymarketSlug(slug: string): boolean {
return typeof slug === 'string' && slug.length > 0 && /^[a-z0-9-]+$/.test(slug) && !slug.endsWith('/') && !slug.includes(' ');
}
if (!isValidPolymarketSlug(slug)) {
// reject early
} Type guard
const isEvent = (e: unknown): e is Event => typeof e === 'object' && e !== null && typeof (e as any).slug === 'string';
Try / catch
try {
const event = await ofetch<Event>(`${GAMMA_API}/events/slug/${slug}`);
if (!event) throw new Error('Event not found');
} catch (e) {
// ofetch throws on HTTP errors; 'Event not found' covers null-body 200s
if (e instanceof Error && e.message === 'Event not found') {
// slug invalid/delisted: advise checking polymarket.com/event/{slug}
}
} Prevention
- Validate the slug format before the fetch.
- Confirm the event exists on polymarket.com before subscribing.
- Strip trailing slashes/whitespace from user-supplied slugs.
When it happens
Trigger: The slug does not correspond to any Polymarket event; the event was delisted/reslugged; the API returned a 200 with an empty body for a malformed slug.
Common situations: Slug typo; outdated slug from an old feed; event merged into a series and slug changed; trailing slash or whitespace in the slug.
Related errors
- Series not found
- Invalid tag slug: ${slug}
- Douban 返回数据结构异常,可能触发反爬或限频。${details ? `上游信息:${details}` : ''
- Douban 返回空数据,可能触发反爬或限频。请稍后重试。
- ${tagResponse.msg}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/233dd15466624f9a.
Report an issue: GitHub.