Skip to content

fix: retry apibay search when it answers with its no-results sentinel - #155

Merged
baairon merged 1 commit into
baairon:mainfrom
zanmlakar:fix/apibay-search-sentinel-retry
Aug 15, 2026
Merged

fix: retry apibay search when it answers with its no-results sentinel#155
baairon merged 1 commit into
baairon:mainfrom
zanmlakar:fix/apibay-search-sentinel-retry

Conversation

@zanmlakar

Copy link
Copy Markdown
Contributor

What and why

apibay's q.php caches search results per exact URL, and a query can get stuck with the single "No results returned" placeholder on one URL form while the alternate form answers fine. torlink always sends the bare form (q.php?q=…), so a poisoned query renders an empty TPB column in every tab even though the index has plenty. This retries once with &cat=0 when the sentinel comes back: the poisoned case turns into results, a genuinely empty search costs one extra request and still comes back empty, and browses (precompiled feeds) never retry.

Measured against the live API today (2026-08-14), stable across repeated runs ~40 minutes apart:

query q.php?q=… q.php?q=…&cat=0
metallica sentinel (5/5) 100 rows (4/4)
abba sentinel (3/3) 100 rows
pink floyd sentinel (3/3) 100 rows
dune 100 rows (3/3) sentinel (3/3)
daft punk · taylor swift · oppenheimer · breaking bad · ubuntu 100 rows 100 rows

Whichever form is poisoned, the other answered in every observed case — hence retry-on-sentinel rather than swapping forms wholesale (dune shows a swap would just move the hole). Live through the patched module: tpbMovies.search("metallica") goes from 0 rows to 9, "abba" from 0 to 8.

The four new tests pin the retry URL, the single-request happy path, the both-forms-empty case, and that browses never retry.

Found while verifying #141's TPB music source against the live API; it affects Movies and TV identically today, so it ships separately as its own concern.

Checklist

  • npm run typecheck is clean
  • npm test passes
  • New logic has a test (vitest; mock node built-ins for platform code)
  • If I added a key, I updated both HELP_GROUPS and footerHints in src/ui/keymap.ts
  • If I added a Store field, I updated makeStore in scripts/render-previews-impl.tsx
  • OS-touching code works on Windows, macOS, and Linux
  • One concern, with a Conventional Commits title (feat: / fix: / docs: / chore:)

@baairon
baairon merged commit d5e75cb into baairon:main Aug 15, 2026
9 checks passed
@baairon

baairon commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Merged, thank you Žan, and nice catch on that sentinel. On the music tab in #141, torlink is in maintenance mode right now so I'm not taking on new features, but I appreciate the work you put into it.

@zanmlakar

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge!

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.

2 participants