Skip to main content
Every API response carries an X-Correlation-Id header, and the API logs start and end lines with it. Grab it first; it makes everything below faster.

Auth

  • The token expired: supabase-js refreshes it, but a token copied into a terminal lasts about an hour.
  • JWT_SECRET doesn’t match the Supabase project that issued the token, or SUPABASE_URL points at a different project (the issuer must be {SUPABASE_URL}/auth/v1).
  • The header isn’t Authorization: Bearer <token>.
The API logs JWT authentication failed with the reason.
The token is fine but public.users.role isn’t admin for that user. Check the row with the user’s sub. If the role lookup itself fails, the API logs [AuthTransform] ERROR fetching role and treats the user as having no role.
The API creates the public.users row on the first write. If that upsert fails (missing table, missing service key), later writes fail too. Check the logs for UserSyncService errors.

Battles and models

The chosen model failed or took longer than 60 seconds, and the fallback model answered. Look for Falling back to basic model in the logs, then check the provider: gateway configuration, key cooldowns in Providers & keys, or the model ID.
The fallback (Groq through AI Gateway) failed too. Usually the AI Gateway settings are missing or wrong: CLOUDFLARE_AI_GATEWAY_ACCOUNT_ID, CLOUDFLARE_AI_GATEWAY_ID, and CLOUDFLARE_AI_GATEWAY_TOKEN when BYOK is on.
Random battles only use active Groq and Google models. Activate at least two, or use Side by Side with Cloudflare models.
The model list is cached for five minutes. Wait, or restart the container. Also check status = active and that provider_name is groq, google or cloudflare.
If the model is inactive, activate it (v_leaderboard only shows active models). If it has no model_leaderboard row, seed one (see Supabase setup).
ComparisonLogger inserts a row for any model name it doesn’t recognise. A typo in a manual battle creates one. Fix the name in the client and remove or deactivate the stray row in the admin panel.

Admin panel

A client sent a partial body to a PUT route. The API writes every DTO field, so missing ones became null. Re-enter the values and make sure the client sends the full record.
Other rows still reference it (comparisons, votes or keys). For a model or provider, deactivate it instead (set the model’s status, or turn the provider off); for a comparison, delete its votes first. The error text is the PostgREST message.
The admin route deletes only the public.users row. Remove the account itself in Supabase Auth.

Infrastructure

The container sleeps 120 minutes after the last request and the cron pings /health every five minutes, so cold starts should be rare. A deploy also starts a fresh container. If they happen often, check the Worker’s cron trigger in the Cloudflare dashboard.
SUPABASE_SERVICE_ROLE_KEY (or SUPABASE_SERVICE_KEY) is missing in that environment.
Check that Telegram__BotToken and Telegram__ApiBaseUrl are set (the bot is disabled otherwise), that the webhook points at /api/telegram/webhook (getWebhookInfo), and that no other process is long-polling the same bot.
Last modified on October 18, 2026