Skip to content

fix: skip Trakt lookups (Methods 2/3) when TRAKT_CLIENT_ID is unset - #87

Open
kilo-WATT wants to merge 1 commit into
Woahai321:mainfrom
kilo-WATT:fix/skip-trakt-when-unconfigured
Open

fix: skip Trakt lookups (Methods 2/3) when TRAKT_CLIENT_ID is unset#87
kilo-WATT wants to merge 1 commit into
Woahai321:mainfrom
kilo-WATT:fix/skip-trakt-when-unconfigured

Conversation

@kilo-WATT

@kilo-WATT kilo-WATT commented Aug 8, 2026

Copy link
Copy Markdown

Bug

process_media_item() has 4 methods for resolving an item to a TMDB ID:

  1. Direct TMDB ID (from the source list)
  2. IMDB ID → Trakt → TMDB ID
  3. Title/Year → Trakt → TMDB ID
  4. Overseerr's own title search (fallback) — referring to ListSync's own naming here (OVERSEERR_URL/OVERSEERR_API_KEY, overseerr_client); my own testing was actually against Seerr (the Overseerr-API-compatible successor project), not Overseerr itself

Methods 2 and 3 call the Trakt API unconditionally — even when TRAKT_CLIENT_ID is completely unset. Since Trakt is meant to be optional (Method 4 exists specifically as the no-Trakt fallback), this means every item still attempts a live call to api.trakt.tv that's guaranteed to fail before falling through.

This isn't just a fast failure. It can trip Trakt's own rate limiter, which triggers a 300-second sleep per item (see the 429 handling already in providers/trakt.py). Running a sync against a few hundred items with no Trakt configured can turn what should be a couple-minute sync into one that effectively never completes.

Repro

  • Fresh install, TRAKT_CLIENT_ID left blank (only MDBLIST_LISTS configured)
  • Ran a sync against a ~540 item MDBList list
  • Log filled with repeated:
    ⚠️  Trakt API rate limit hit. Waiting 300 seconds...
    
  • Sync did not meaningfully progress until Trakt calls were manually disabled

This is likely related to what's being reported in #85 and #68 — Trakt has been increasingly hostile to unauthenticated/misconfigured callers, so hitting it unnecessarily is more costly now than it used to be.

Fix

  • Added is_trakt_configured() to providers/trakt.py — checks config/env for a Trakt Client ID without raising.
  • Gated Methods 2 and 3 on it in main.py. When Trakt isn't configured, each logs a clear skip message and falls straight through (Method 2 → Method 3 → Method 4) instead of attempting the network call.
  • No change in behavior when Trakt is configured — same 4-method chain as before.

Testing

  • python3 -m py_compile clean on both changed files
  • Verified in a real deployment (Seerr as the request backend): same ~540 item list, same missing TRAKT_CLIENT_ID, sync now completes normally instead of stalling on rate-limit sleeps

Methods 2 and 3 in process_media_item() unconditionally call the Trakt
API for IMDB->TMDB and Title->TMDB resolution, even when no
TRAKT_CLIENT_ID is configured at all. Since Trakt is optional (Method 4
falls back to Overseerr's own search), this means every single
processed item still attempts a live network call to api.trakt.tv that
is guaranteed to fail.

In practice this doesn't just fail fast: it can trip Trakt's rate
limiter, which forces a 300-second sleep per item (see the 429 handling
in providers/trakt.py). With a few hundred items and no Trakt
configured, this can turn a sync that should take a couple of minutes
into one that effectively never finishes.

This adds is_trakt_configured() to providers/trakt.py (checks config/env
without raising) and gates Methods 2 and 3 on it, logging a clear skip
message and falling straight through to Method 4 instead.

Observed while running a ~540 item MDBList sync with no Trakt
configured: sync stalled on repeated "Trakt API rate limit hit. Waiting
300 seconds..." messages until Trakt calls were manually disabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant