BUG: Proxy routes use legacy single-instance environment variables instead of multi-instance config #33

Closed
opened 2026-05-22 18:53:22 +01:00 by Gandalf · 1 comment
Owner

Summary

The proxy routes for Sonarr, Radarr, and SABnzbd (/queue, /history, /series, /notifications/:id, /notifications (POST/PUT/DELETE), etc.) bypass the modern multi-instance configurations and are hardcoded to use legacy single-instance environment variables (process.env.SONARR_URL, process.env.SONARR_API_KEY, etc.).

Root Cause

In server/routes/sonarr.js, server/routes/radarr.js, and server/routes/sabnzbd.js, endpoints retrieve information by direct request using the legacy environment variables:

const response = await axios.get(`${process.env.SONARR_URL}/api/v3/queue`, {
  headers: { 'X-Api-Key': process.env.SONARR_API_KEY }
});

This is inconsistent with other parts of the system, such as server/utils/config.js and some /notifications endpoints, which correctly use multi-instance configurations (e.g. getSonarrInstances()).

Impact

In environments configured exclusively with the modern multi-instance JSON arrays (e.g. SONARR_INSTANCES), these proxy routes will fail completely with connection errors or TypeError because legacy environment variables are undefined.

Steps to Reproduce

  1. Configure SONARR_INSTANCES via JSON array in the environment variables, leaving SONARR_URL and SONARR_API_KEY undefined.
  2. Log in and hit the /api/sonarr/queue or /api/sonarr/history endpoint.
  3. The request will fail with an error or a TypeError since process.env.SONARR_URL is undefined.

Proposed Fix

Update these route controllers to:

  1. Import configuration instance getters (e.g., getSonarrInstances(), getRadarrInstances(), getSABnzbdInstances()).
  2. Implement fallback logic to retrieve the first configured instance as default (using helpers like getFirstSonarrInstance() for all endpoints in the router).
  3. Update all AXIOS requests to use instance.url and instance.apiKey dynamically.
### Summary The proxy routes for Sonarr, Radarr, and SABnzbd (`/queue`, `/history`, `/series`, `/notifications/:id`, `/notifications` (POST/PUT/DELETE), etc.) bypass the modern multi-instance configurations and are hardcoded to use legacy single-instance environment variables (`process.env.SONARR_URL`, `process.env.SONARR_API_KEY`, etc.). ### Root Cause In `server/routes/sonarr.js`, `server/routes/radarr.js`, and `server/routes/sabnzbd.js`, endpoints retrieve information by direct request using the legacy environment variables: ```javascript const response = await axios.get(`${process.env.SONARR_URL}/api/v3/queue`, { headers: { 'X-Api-Key': process.env.SONARR_API_KEY } }); ``` This is inconsistent with other parts of the system, such as `server/utils/config.js` and some `/notifications` endpoints, which correctly use multi-instance configurations (e.g. `getSonarrInstances()`). ### Impact In environments configured exclusively with the modern multi-instance JSON arrays (e.g. `SONARR_INSTANCES`), these proxy routes will fail completely with connection errors or `TypeError` because legacy environment variables are undefined. ### Steps to Reproduce 1. Configure `SONARR_INSTANCES` via JSON array in the environment variables, leaving `SONARR_URL` and `SONARR_API_KEY` undefined. 2. Log in and hit the `/api/sonarr/queue` or `/api/sonarr/history` endpoint. 3. The request will fail with an error or a `TypeError` since `process.env.SONARR_URL` is undefined. ### Proposed Fix Update these route controllers to: 1. Import configuration instance getters (e.g., `getSonarrInstances()`, `getRadarrInstances()`, `getSABnzbdInstances()`). 2. Implement fallback logic to retrieve the first configured instance as default (using helpers like `getFirstSonarrInstance()` for all endpoints in the router). 3. Update all AXIOS requests to use `instance.url` and `instance.apiKey` dynamically.
Gandalf added the Kind/Bug label 2026-05-22 19:16:27 +01:00
Author
Owner

Resolved via commit 2e9fe8e.

Resolved via commit 2e9fe8e.
Gandalf added the Area/Proxy label 2026-05-28 11:53:58 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/sofarr#33