9. Trigger Challenge Images
Purpose: Resolve anti-spoiler images for challenge content via the RESOLVE_CHALLENGE_IMAGE queue. The handler cascades through image providers (Wikimedia Commons, Unsplash, Pexels) and skips gracefully if none return a match.
Prerequisites:
- worker-ingest running (
bun run dev:worker-ingest) .env.localwithSUPABASE_URL,SUPABASE_SERVICE_ROLE_KEY,UPSTASH_REDIS_REST_URL,UPSTASH_REDIS_REST_TOKEN- Optional:
UNSPLASH_ACCESS_KEY,PEXELS_API_KEYfor extended provider cascade
Cost / Duration: $0 (free image APIs) | ~2 minutes
Prompt
Trigger challenge image resolution for facts that are missing images.
Step 1 — Start the ingestion worker (if not already running):
```bash
bun run dev:worker-ingest
```
Step 2 — Find facts missing challenge images and enqueue them:
```sql
-- Find validated facts without challenge images
SELECT id, title, topic_category_id
FROM fact_records
WHERE status = 'validated'
AND challenge_image_url IS NULL
LIMIT 20;
```
Step 3 — Enqueue RESOLVE_CHALLENGE_IMAGE messages for each fact.
The worker handler will:
1. Look up the fact's entity name and topic context
2. Try Wikimedia Commons first (free, no API key)
3. Fall back to Unsplash (if UNSPLASH_ACCESS_KEY is set)
4. Fall back to Pexels (if PEXELS_API_KEY is set)
5. Skip gracefully if no provider returns a match
Check worker-ingest logs for:
- `Processing RESOLVE_CHALLENGE_IMAGE` (start)
- `Challenge image resolved` or `No challenge image found` (result)
Verification
- worker-ingest processes RESOLVE_CHALLENGE_IMAGE messages
- Facts with resolved images have
challenge_image_urlpopulated - Facts without available images are skipped (not errored)
- No uncaught errors in worker logs
Related Prompts
- Start Workers -- Start all pipeline workers
- Check Queue Health -- Verify queue state