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

  1. Open https://polymarket.com/event/{slug} to confirm the event exists and the slug is current.
  2. Copy the slug exactly from the current Polymarket URL path.
  3. Strip whitespace/slashes from the slug before subscribing.
  4. 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

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


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/233dd15466624f9a. Report an issue: GitHub.