fix(prowlarr-import): build proxy URLs from the base Prowlarr answered on - #876
Open
m4bard wants to merge 1 commit into
Open
fix(prowlarr-import): build proxy URLs from the base Prowlarr answered on#876m4bard wants to merge 1 commit into
m4bard wants to merge 1 commit into
Conversation
…d on Importing indexers from a Prowlarr instance that runs under a URL base stored every proxy URL without that base. The discovery request to /api/v1/indexer is redirected onto the base and Listenarr follows it, so the import reports success, but each indexer's URL was composed from the address that was typed in rather than the one that answered. SendWithValidatedRedirectsAsync already returns the final URI and the workflow discarded it. Keep it, strip the discovery path off the end, and use what is left as the base for BuildProxyUrl and for the tag lookup.
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.
Fixes #875.
Importing indexers from a Prowlarr instance that runs under a URL base stored every proxy URL without that base:
The discovery request to
/api/v1/indexeris redirected onto the base and Listenarr follows it, so the import reports success. Each indexer's URL was then composed from the address that was typed in rather than the one that answered.OutboundRequestSecurity.SendWithValidatedRedirectsAsyncalready returns the final URI, andProwlarrIndexerImportWorkflow.SendValidatedAsyncwas discarding it (var (response, _) = ...). This keeps it, strips the discovery path off the end, and uses the remainder as the base forBuildProxyUrland for the tag lookup.Change
ProwlarrImportUrlPlanner.ResolveBaseUrlFromDiscoveryis new: given the requested base, the URI the discovery call finished on, and the discovery path, return the base Prowlarr actually answered on. It falls back to the requested base when there was no redirect or when the final path does not end in the discovery path.ProwlarrIndexerImportWorkflow.SendValidatedAsyncreturns the final URI instead of dropping it, andFetchProwlarrIndexersAsyncpasses it back with the payload.ImportAsyncresolves the effective base once and uses it for bothBuildProxyUrlandTryFetchProwlarrTagMapAsync, and logs at Information when the two differ.46 added, 13 removed across two files. The address the user typed is still what gets saved to the Prowlarr import settings; the redirect only affects how proxy URLs are composed, so a re-import recomputes the same thing rather than quietly rewriting what the user entered.
Diagram
stateDiagram-v2 direction TB [*] --> Requested: user supplies a Prowlarr address Requested --> Discovery: GET {base}/api/v1/indexer Discovery --> Answered: 2xx, possibly after a redirect Discovery --> Failed: unreachable or non-2xx Answered --> Resolved: strip /api/v1/indexer off the URI that answered Resolved --> Stored: BuildProxyUrl(resolved base, indexer id) Failed --> [*] Stored --> [*]Before this change the
Resolvedstep did not exist andStoredread straight fromRequested. Those are the same value whenever Prowlarr sits at the root, which is presumably why it went unnoticed.Tests
tests/Features/Api/Features/Prowlarr/ProwlarrImportUrlBaseTests.cs, two cases:/prowlarr: the stored URL ishttp://prowlarr.example:9696/prowlarr/4/api, and the redirected discovery request is asserted to have happened.http://prowlarr.example:9696/4/api, unchanged from today.Control: with both production files reverted, the first case fails with
http://prowlarr.example:9696/4/apiagainst an expectedhttp://prowlarr.example:9696/prowlarr/4/api, and the second still passes. Full suite is green.