Skip to content

fix(server): don't overwrite shared *arr host/token on empty-credential polls - #361

Open
Davixk wants to merge 1 commit into
sirrobot01:betafrom
Davixk:fix/arr-credentials-wiped-by-empty-poll
Open

Davixk wants to merge 1 commit into
sirrobot01:betafrom
Davixk:fix/arr-credentials-wiped-by-empty-poll

Conversation

@Davixk

@Davixk Davixk commented Jul 26, 2026

Copy link
Copy Markdown

What breaks: after Sonarr/Radarr have been polling for a while, every *arr starts reporting "arr not configured" until its host/token is re-saved in the UI. Repair sweeps fail for the same reason.

Why: authenticate in pkg/server/qbit/context.go and pkg/server/sabnzbd/context.go overwrites the shared *arr.Arr's Host/Token in place whenever a.Source == "auto", unconditionally. A poll that arrives with blank download-client credentials therefore sets them to "". Because the *arr.Arr is shared through the manager's arr map, that corrupts the entry for every other consumer, not just the polling request. The functions already apply an empty-credential guard a few lines lower, before AddOrUpdate — the in-place mutation just isn't covered by it.

The fix: only adopt credentials from a poll when both username and password are non-empty. A poll with valid credentials still populates or updates an auto arr; an empty-credential poll no longer wipes one.

Evidence: running in production on a ~47,000-entry library. Regression and positive tests added to both packages; the regression tests fail on beta without the change.

…al polls

The qBittorrent and SABnzbd auth middleware overwrote a shared in-memory
*arr.Arr's Host/Token in place whenever a.Source == "auto", unconditionally —
even when the incoming credentials were empty. When Sonarr/Radarr polled
GET /torrents/info (or the SAB equivalent) with blank download-client
credentials, they wiped the shared arr's Host and Token to "", corrupting the
arr for every other consumer of the shared arr map — notably the repair
service, which then rejects the arr with "arr not configured".

Guard the mutation so it only overwrites when BOTH incoming credentials are
non-empty, mirroring the empty-guard these functions already apply before their
AddOrUpdate call. A poll with valid creds still populates/updates an auto arr;
an empty-cred poll no longer wipes an already-populated one.

Adds regression + positive tests to both the qbit and sabnzbd packages.
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