Skip to content

fix(prowlarr): send categories as repeated query params - #2

Open
strass wants to merge 1 commit into
bandoracer:mainfrom
strass:main
Open

strass wants to merge 1 commit into
bandoracer:mainfrom
strass:main

Conversation

@strass

@strass strass commented Aug 1, 2026

Copy link
Copy Markdown

Symptom

Ebook searches work. Audiobook searches always return HTTP 502, on every
query term and every indexer, with no user-visible setting that differs
between the two:

POST /api/v1/releases/search  {"query":"the hobbit","format":"audiobook",...}
-> 502  {"error":"prowlarr search returned 400 Bad Request"}

Root cause

ProwlarrClient.searchOnce (backend/internal/acquisition/prowlarr.go)
built the category parameter with url.Values.Set and a comma-joined
string from categoriesForFormat:

format value encodes to result
ebook / book 7000 categories=7000 200
audiobook/audio 7000,3030 categories=7000%2C3030 400
"" / any 7000,3030 categories=7000%2C3030 400

Prowlarr's /api/v1/search binds categories as an array of int, which
in ASP.NET means a repeated parameter, not a comma-separated string.
It rejects the comma-joined form during model binding:

"categories": {
  "rawValue": "7000,3030",
  "errors": [{ "errorMessage": "The value '7000,3030' is not valid." }],
  "validationState": "invalid"
}

Librarry surfaces that upstream 400 to the browser as a 502.

Ebook searches were unaffected only incidentally: a single category has
no comma to mis-encode.

Confirmed against Prowlarr directly (same query, same indexers):

categories=7000%2C3030          -> 400
categories=7000&categories=3030 -> 200
categories=7020                 -> 200

Fix

Add categoryListForFormat, which splits the same list so each category
is appended with url.Values.Add, producing repeated parameters.

categoriesForFormat is deliberately retained: fetchIndexerFeed uses
it for the Newznab feed endpoint, where a comma-joined cat parameter
is the correct convention. Only the Prowlarr JSON search path changed.

Verification

  • go build ./... — clean
  • go test ./... — all pass, no regressions
  • New regression test TestProwlarrSearchSendsRepeatedCategoryParamsForAudiobooks
    fails without the fix (categories were comma-joined into one parameter)
    and passes with it
  • gofmt clean; patch applies cleanly to pristine upstream at the above revision

Prowlarr's /api/v1/search binds `categories` as an array of int, which
requires a repeated query parameter (categories=7000&categories=3030).
searchOnce used url.Values.Set with a comma-joined string, so any format
resolving to more than one category produced categories=7000%2C3030 and
Prowlarr rejected it with 400 Bad Request:

    "categories": { "rawValue": "7000,3030",
      "errors": [{ "errorMessage": "The value '7000,3030' is not valid." }],
      "validationState": "invalid" }

librarry surfaces that upstream failure to the browser as a 502.

This hit audiobook searches (7000,3030) and the "any" format on every
query regardless of search term or indexer. Ebook searches were
unaffected only incidentally, because "7000" is a single value with no
comma to mis-encode.

Add categoryListForFormat, which splits the same list for use with
url.Values.Add. categoriesForFormat is retained for fetchIndexerFeed:
the Newznab feed endpoint takes a comma-joined `cat` parameter, which
is the correct convention there and must not change.
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