fix: skip Trakt lookups (Methods 2/3) when TRAKT_CLIENT_ID is unset - #87
Open
kilo-WATT wants to merge 1 commit into
Open
fix: skip Trakt lookups (Methods 2/3) when TRAKT_CLIENT_ID is unset#87kilo-WATT wants to merge 1 commit into
kilo-WATT wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
process_media_item()has 4 methods for resolving an item to a TMDB ID:OVERSEERR_URL/OVERSEERR_API_KEY,overseerr_client); my own testing was actually against Seerr (the Overseerr-API-compatible successor project), not Overseerr itselfMethods 2 and 3 call the Trakt API unconditionally — even when
TRAKT_CLIENT_IDis 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 toapi.trakt.tvthat'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
TRAKT_CLIENT_IDleft blank (onlyMDBLIST_LISTSconfigured)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
is_trakt_configured()toproviders/trakt.py— checks config/env for a Trakt Client ID without raising.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.Testing
python3 -m py_compileclean on both changed filesTRAKT_CLIENT_ID, sync now completes normally instead of stalling on rate-limit sleeps