Skip to content

feat(music): add Lidarr server settings and connectivity - #3109

Merged
gauthier-th merged 2 commits into
seerr-team:musicfrom
Crow-Control:lidarr
Jun 8, 2026
Merged

gauthier-th merged 2 commits into
seerr-team:musicfrom
Crow-Control:lidarr

Conversation

@Crow-Control

@Crow-Control Crow-Control commented Jun 3, 2026 •

Copy link
Copy Markdown

Description

This is the Lidarr-server addition portion of the ongoing project to add music support (#2132) to Seerr.
It's seperated into a functionally stand-alone PR, to ensure review-ability.
It also cuts down the PR scope of the music PR by more than 10%

It can be used and configured, without any of the other music-support code present.
Added to this is a bunch of documentation, to ensure it meets quality standards, seperate of future music handling.

No new tests are added, because the Radarr and Sonarr server-connection api's, also dont feature seperate tests. But are tested as part of the (future) processing stack

In short:
This PR adds a reviewable, cleaned-up, Lidarr connectivity API and interface

AI used:

  • Copilot-auto code-review
  • Claude Opus 4.7 code-review
  • Claude Opus 4.7 for bulk splitting of this code from other commits
  • Copilot-auto is used to highlight all sections needing doc updates and pre-write them

How Has This Been Tested?

  • Manually build
  • Manually dev-run
  • Manually connected with a Lidarr server
  • Some manual API calls to ensure they get routed
  • pnpm typecheck
  • pnpm lint
  • Prettier --check

Screenshots / Logs (if applicable)

Screenshot 2026-06-03 at 16 49 32 Screenshot 2026-06-03 at 16 49 36 Screenshot 2026-06-03 at 16 49 40

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required) -> Not required

Summary by CodeRabbit

  • New Features

    • Lidarr integration: add, test, edit, list, and manage Lidarr music servers from Settings; view server details and run scans.
  • Documentation

    • README, docs, and Settings guidance updated to include Lidarr support and backup/restore coverage.
  • UI

    • New Lidarr add/edit modal, settings section, labels, and validation/messages for music service configuration.

Copilot AI review requested due to automatic review settings June 3, 2026 14:51
@Crow-Control
Crow-Control requested a review from a team as a code owner June 3, 2026 14:51
@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 41fb43a7-c127-4e53-b1c5-3fc428a3fae0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Seerr gains full Lidarr music library support: API spec and schema, backend LidarrAPI client, cache and settings integration, service/settings routes, React add/edit modal with test-connection flow, documentation updates, and i18n strings.

Changes

Lidarr Music Library Integration

Layer / File(s) Summary
API specification and documentation updates
README.md, docs/README.md, docs/using-seerr/backups.md, docs/using-seerr/settings/services.md, seerr-api.yml
OpenAPI spec adds LidarrSettings schema and endpoints for /settings/lidarr and /service/lidarr. User docs and READMEs updated to describe Lidarr integration and configuration guidance.
Backend infrastructure: cache, settings types, API client
server/lib/cache.ts, server/lib/settings/index.ts, server/api/servarr/lidarr.ts
Adds lidarr cache id and registration, LidarrSettings type and lidarr-scan job, and LidarrAPI client with album listing, MBID search, add/remove album logic, metadata profile retrieval, and error wrapping.
Service router: Lidarr instance discovery
server/routes/service.ts
Adds /lidarr and /lidarr/:id endpoints to enumerate configured Lidarr servers and fetch per-server profiles, root folders, and tags for UI consumption.
Settings router: Lidarr configuration management
server/routes/settings/index.ts, server/routes/settings/lidarr.ts
CRUD endpoints for Lidarr settings (list, create with auto-increment ID and default semantics, test connection aggregating profiles/folders/tags, update, fetch profiles, delete).
Frontend UI: Lidarr modal and settings page integration
src/components/Settings/LidarrModal/index.tsx, src/components/Settings/SettingsServices.tsx
Adds LidarrModal with Formik/Yup validation, test-connection POST to /api/v1/settings/lidarr/test, react-select tag picker, and SettingsServices integration (SWR hook, Lidarr section, add/edit/delete wiring).
Internationalization: Lidarr UI strings
src/i18n/locale/en.json
Adds English translations for Lidarr modal fields, validation messages, test-toasts, "Add Lidarr Server" label, music media type, and separate music/video service descriptions.
Error handling improvements
server/routes/media.ts
Media deletion endpoint now returns explicit HTTP 500 JSON response and improved log messaging when no default service is configured.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • fallenbagel
  • gauthier-th

Poem

I’m a rabbit in the code, with a nose for song and beat,
I hopped through configs, APIs, and made the music route complete,
Albums now arrive, profiles and tags in line,
I tested connections, sampled bytes, and sorted every fine,
Tap your paws — Lidarr’s here, your library’s now replete.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title 'feat(music): add Lidarr server settings and connectivity' accurately describes the main change—adding Lidarr server configuration and API support—and is specific, concise, and clearly related to the comprehensive set of changes across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Lidarr support across the app (UI, server routes, settings model, API docs, and documentation) so users can configure Lidarr servers similarly to Radarr/Sonarr.

Changes:

  • Introduces Lidarr settings UI (services page section + new Lidarr modal) and new i18n strings.
  • Adds Lidarr server routes and a Lidarr Servarr API wrapper, plus settings/cache plumbing.
  • Updates OpenAPI spec and docs to include Lidarr.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/i18n/locale/en.json Adds Lidarr-related UI strings and splits video vs music service descriptions
src/components/Settings/SettingsServices.tsx Adds Lidarr section, modal wiring, and updated description messages
src/components/Settings/LidarrModal/index.tsx New modal to create/edit/test Lidarr server configuration
src/assets/services/lidarr.svg Adds Lidarr logo asset for UI
server/routes/settings/lidarr.ts New CRUD + test endpoints for Lidarr settings
server/routes/settings/index.ts Registers the new Lidarr settings router
server/routes/service.ts Adds service endpoints for Lidarr server list/details
server/routes/media.ts Improves error handling when no default service server is configured
server/lib/settings/index.ts Adds LidarrSettings type, settings storage, and lidarr-scan job id/default schedule
server/lib/cache.ts Adds Lidarr cache id/instance and fixes union formatting
server/api/servarr/lidarr.ts Adds Lidarr API client wrapper (albums/search/profiles)
seerr-api.yml Documents Lidarr settings/service endpoints and schema
docs/using-seerr/settings/services.md Documents Lidarr configuration alongside Radarr/Sonarr
docs/using-seerr/backups.md Notes Lidarr config is included in backups
docs/README.md Adds Lidarr to docs landing page feature list
README.md Adds Lidarr to main README feature list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/routes/settings/lidarr.ts Resolved
Comment thread server/routes/settings/lidarr.ts Resolved
Comment thread seerr-api.yml Resolved
Comment thread seerr-api.yml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/routes/media.ts (1)

288-293: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Return correct status codes in delete-file catch path.

This catch still returns 404 Media not found for every failure, including Radarr/Sonarr/TMDB errors and TVDB ID not found. That misclassifies operational failures and breaks client error handling.

Suggested fix
     } catch (e) {
       logger.error('Something went wrong deleting media file', {
         label: 'Media',
         message: e.message,
       });
-      next({ status: 404, message: 'Media not found' });
+      if (e instanceof EntityNotFoundError) {
+        return next({ status: 404, message: 'Media not found' });
+      }
+      return next({ status: 500, message: 'Failed to delete media file' });
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/routes/media.ts` around lines 288 - 293, The catch block in the media
delete handler currently logs the error with logger.error and always calls
next({ status: 404, message: 'Media not found' }), which misclassifies failures
(Radarr/Sonarr/TMDB errors, TVDB not found, internal failures). Update the catch
to inspect the thrown error (e.g., check error.status / error.code / error.name
or specific messages from Radarr/Sonarr/TMDB integrations) and map to
appropriate HTTP statuses before calling next; for example propagate 404 for
genuine missing-media errors, 502/504 for upstream service failures, 500 for
unexpected/internal errors, and preserve the original error.message in the
next() call. Modify the existing logger.error(...) call to include the full
error object and context, and replace the hardcoded next({ status: 404, ... })
with logic that derives status and message from the caught error so callers
receive correct status codes.
🧹 Nitpick comments (4)
src/components/Settings/SettingsServices.tsx (1)

577-577: 💤 Low value

Simplify boolean prop assignment.

The explicit isLidarr={true} assignment can be simplified to just isLidarr since it's a boolean prop. This is more idiomatic in React.

♻️ Optional simplification
-                  isLidarr={true}
+                  isLidarr
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Settings/SettingsServices.tsx` at line 577, The prop usage
sets isLidarr explicitly to true (isLidarr={true}); simplify by using the
boolean shorthand isLidarr instead. Locate the JSX element in
SettingsServices.tsx where isLidarr is passed (the component invocation that
currently contains isLidarr={true}) and replace that assignment with just
isLidarr to follow idiomatic React boolean prop syntax.
server/api/servarr/lidarr.ts (1)

325-336: ⚡ Quick win

Duplicate method: searchAlbum and searchAlbumByMusicBrainzId are identical.

Both methods issue the exact same GET /search with term: lidarr:<mbid>; only the error message differs. Consolidate to a single method (or have one delegate to the other) to avoid divergence.

♻️ Suggested consolidation
-  public async searchAlbum(mbid: string): Promise<LidarrAlbumResult[]> {
-    try {
-      const data = await this.get<LidarrAlbumResult[]>('/search', {
-        params: {
-          term: `lidarr:${mbid}`,
-        },
-      });
-      return data;
-    } catch (e) {
-      throw new Error(`[Lidarr] Failed to search album: ${e.message}`);
-    }
-  }
+  // removed: superseded by searchAlbumByMusicBrainzId

Then update callers of searchAlbum to use searchAlbumByMusicBrainzId.

Also applies to: 393-408

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/servarr/lidarr.ts` around lines 325 - 336, Two identical methods,
searchAlbum and searchAlbumByMusicBrainzId, both call GET /search with
term:`lidarr:<mbid>` — consolidate them to a single implementation to avoid
duplication: keep one canonical method (e.g., searchAlbumByMusicBrainzId)
containing the try/catch and API call, remove the duplicated implementation from
the other method and either delete it or make it delegate (return
this.searchAlbumByMusicBrainzId(mbid)); update all callers to use the canonical
method name; preserve the same error wrapping (use e.message) when moving the
logic so behavior stays identical.
server/routes/settings/lidarr.ts (2)

50-53: 💤 Low value

Optional: parallelize the independent Lidarr lookups.

getProfiles, getMetadataProfiles, getRootFolders, and getTags are independent and currently run sequentially. Running them with Promise.all would reduce the /test round-trip latency.

♻️ Proposed refactor
-    const profiles = await lidarr.getProfiles();
-    const metadataProfiles = await lidarr.getMetadataProfiles();
-    const folders = await lidarr.getRootFolders();
-    const tags = await lidarr.getTags();
+    const [profiles, metadataProfiles, folders, tags] = await Promise.all([
+      lidarr.getProfiles(),
+      lidarr.getMetadataProfiles(),
+      lidarr.getRootFolders(),
+      lidarr.getTags(),
+    ]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/routes/settings/lidarr.ts` around lines 50 - 53, The four independent
Lidarr calls (getProfiles, getMetadataProfiles, getRootFolders, getTags) are
currently awaited sequentially; replace them with a parallel call using
Promise.all — e.g. call Promise.all([lidarr.getProfiles(),
lidarr.getMetadataProfiles(), lidarr.getRootFolders(), lidarr.getTags()]) and
destructure the resulting array into profiles, metadataProfiles, folders, tags
so the /test handler completes faster; ensure you preserve existing error
behavior (propagate or catch errors as before) or use Promise.allSettled if you
need partial results.

122-122: 💤 Low value

Ensure consistent error response/logging for lidarr.getProfiles()

In Express 5, a rejected promise/throw from this async handler is automatically forwarded to the error-handling middleware, so it shouldn’t crash the process. However, this path may not produce the same logger.error + Failed to connect to Lidarr behavior as the /test handler—ensure the shared error middleware returns a suitable client-facing message (or add local handling if you want parity).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/routes/settings/lidarr.ts` at line 122, The call to
lidarr.getProfiles() in the async route handler can reject and currently relies
on Express error middleware, which may not log or return the same client message
as the /test handler; wrap the call in a try/catch around the existing handler
(or mirror the /test handler behavior) to catch errors from
lidarr.getProfiles(), call logger.error with the caught error and a descriptive
message (e.g., "Failed to connect to Lidarr"), and then either return
res.status(500).json({ message: 'Failed to connect to Lidarr' }) or call
next(err) after logging so the client-facing response matches the /test path.
Ensure you reference the getProfiles call and logger.error in your change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@seerr-api.yml`:
- Around line 7593-7596: The public service responses for /service/lidarr*
currently reference the internal LidarrSettings schema which contains sensitive
fields like apiKey and admin-only config; create a new sanitized schema (e.g.,
PublicLidarrSettings or LidarrSettingsPublic) that omits apiKey and any
admin-only properties and update the endpoints that currently $ref
'`#/components/schemas/LidarrSettings`' to reference the new public schema instead
(also update the other occurrence noted); keep the internal LidarrSettings for
admin/internal APIs only and ensure the new schema is used for all public
/service/lidarr* responses.
- Around line 7599-7621: The response schema for GET /service/lidarr/{lidarrId}
is wrong: "profiles" is a single ServiceProfile and the other Lidarr collections
are missing. Update the response object so collection fields are arrays (e.g.,
change "profiles" to type: array with items $ref:
'`#/components/schemas/ServiceProfile`') and add the other collections returned by
the service route as array properties (for example rootFolders, tags, indexers,
etc.) each using their appropriate component schema references; keep the
top-level "server" as the LidarrSettings object and ensure the response schema
remains type: object.
- Around line 3069-3109: The 200 response schema for the Lidarr connection-test
only returns "profiles" but must also include root folders, metadata profiles
and tags used by the setup flow; update the response object under the existing
200 response schema (the response block currently defining "profiles" and
referencing ServiceProfile) to add properties rootFolders (array),
metadataProfiles (array) and tags (array) with appropriate item $ref entries
(e.g. `#/components/schemas/ServiceRootFolder`,
`#/components/schemas/MetadataProfile`, `#/components/schemas/Tag` or create these
component schemas if missing) so the generated client sees the full payload.

In `@server/api/servarr/lidarr.ts`:
- Around line 338-391: The existence check in addAlbum uses this.get('/album',
...) which may return stale cached results because ExternalAPI.get supports a
ttl parameter and cache isn’t invalidated after the subsequent axios.put or
this.post; fix by forcing a fresh fetch for the existence check (call
this.get('/album', { params: {...}, ttl: 0 }) or equivalent to bypass cache) and
ensure you invalidate or refresh the album cache after mutating calls (after
axios.put in the monitored-update branch and after this.post when creating a new
album) so future calls see the updated monitored state; keep the post return
handling as-is since ExternalAPI.post<T>() returns response.data.

In `@server/routes/settings/lidarr.ts`:
- Around line 83-85: The error handling is passing HTTP status codes as strings;
update all calls that invoke next({...}) with status values like '404' to use
numeric codes (e.g., 404) instead; specifically find the branches that check
lidarrIndex (and any other "Settings instance not found" or similar branches in
lidarr.ts) and replace status: '404' with status: 404 so downstream error
handling (res.status(err.status || 500)) receives a number.

In `@src/components/Settings/LidarrModal/index.tsx`:
- Line 249: The defaulting of activeMetadataProfileId to the hardcoded value 1
(activeMetadataProfileId: lidarr?.activeMetadataProfileId ?? 1) can point to a
non-existent profile; change initialization so activeMetadataProfileId is
undefined by default (or set from testResponse.metadataProfiles when available)
and after a successful connection/test populate activeMetadataProfileId with
either the server-returned lidarr.activeMetadataProfileId or the first id from
testResponse.metadataProfiles; update any save/validation logic to require the
user to select or confirm a profile if activeMetadataProfileId is undefined.
- Around line 331-333: The auto-fill should only run when baseUrl is empty and
must not overwrite with undefined or an invalid '/' value: change the condition
on values.baseUrl in the block that calls setFieldValue('baseUrl',
testResponse.urlBase) to only trigger when values.baseUrl is falsy and
testResponse.urlBase is a non-empty string (e.g. check testResponse.urlBase !==
undefined && testResponse.urlBase !== ''), or otherwise skip setting it;
references: values.baseUrl, setFieldValue, and testResponse.urlBase.
- Around line 254-256: The profile name lookups using
testResponse.profiles.find(...) and testResponse.metadataProfiles.find(...) can
return undefined; update the save/submit logic that constructs LidarrSettings so
that after resolving profileName (from testResponse.profiles and
values.activeProfileId) and metadataProfileName (from
testResponse.metadataProfiles and values.activeMetadataProfileId) you validate
both are non-empty strings—if either lookup returns undefined, surface a clear
user error (e.g., set form error or show toast) and abort the save instead of
sending an incomplete object; ensure activeProfileName and
activeMetadataProfileName are only set when the finds succeed and prevent the
submission path that constructs LidarrSettings until validation passes.
- Around line 291-293: The empty catch in the LidarrModal submit handler is
swallowing errors; update the catch to accept the error (e.g., catch (err)) and
surface it to the user and logs: call your toast/error notification utility
(e.g., toast.error) with a clear message like "Failed to save Lidarr settings"
plus err.message, set any submission state back to false (e.g., setIsSubmitting
or setIsSaving) and optionally store the error in component state (e.g.,
setError) so the UI can reflect the failure; also log the full error to console
or logger for debugging. Apply this change inside the LidarrModal component's
submit handler (e.g., handleSubmit/onSubmit) where the POST/PUT is performed.

---

Outside diff comments:
In `@server/routes/media.ts`:
- Around line 288-293: The catch block in the media delete handler currently
logs the error with logger.error and always calls next({ status: 404, message:
'Media not found' }), which misclassifies failures (Radarr/Sonarr/TMDB errors,
TVDB not found, internal failures). Update the catch to inspect the thrown error
(e.g., check error.status / error.code / error.name or specific messages from
Radarr/Sonarr/TMDB integrations) and map to appropriate HTTP statuses before
calling next; for example propagate 404 for genuine missing-media errors,
502/504 for upstream service failures, 500 for unexpected/internal errors, and
preserve the original error.message in the next() call. Modify the existing
logger.error(...) call to include the full error object and context, and replace
the hardcoded next({ status: 404, ... }) with logic that derives status and
message from the caught error so callers receive correct status codes.

---

Nitpick comments:
In `@server/api/servarr/lidarr.ts`:
- Around line 325-336: Two identical methods, searchAlbum and
searchAlbumByMusicBrainzId, both call GET /search with term:`lidarr:<mbid>` —
consolidate them to a single implementation to avoid duplication: keep one
canonical method (e.g., searchAlbumByMusicBrainzId) containing the try/catch and
API call, remove the duplicated implementation from the other method and either
delete it or make it delegate (return this.searchAlbumByMusicBrainzId(mbid));
update all callers to use the canonical method name; preserve the same error
wrapping (use e.message) when moving the logic so behavior stays identical.

In `@server/routes/settings/lidarr.ts`:
- Around line 50-53: The four independent Lidarr calls (getProfiles,
getMetadataProfiles, getRootFolders, getTags) are currently awaited
sequentially; replace them with a parallel call using Promise.all — e.g. call
Promise.all([lidarr.getProfiles(), lidarr.getMetadataProfiles(),
lidarr.getRootFolders(), lidarr.getTags()]) and destructure the resulting array
into profiles, metadataProfiles, folders, tags so the /test handler completes
faster; ensure you preserve existing error behavior (propagate or catch errors
as before) or use Promise.allSettled if you need partial results.
- Line 122: The call to lidarr.getProfiles() in the async route handler can
reject and currently relies on Express error middleware, which may not log or
return the same client message as the /test handler; wrap the call in a
try/catch around the existing handler (or mirror the /test handler behavior) to
catch errors from lidarr.getProfiles(), call logger.error with the caught error
and a descriptive message (e.g., "Failed to connect to Lidarr"), and then either
return res.status(500).json({ message: 'Failed to connect to Lidarr' }) or call
next(err) after logging so the client-facing response matches the /test path.
Ensure you reference the getProfiles call and logger.error in your change.

In `@src/components/Settings/SettingsServices.tsx`:
- Line 577: The prop usage sets isLidarr explicitly to true (isLidarr={true});
simplify by using the boolean shorthand isLidarr instead. Locate the JSX element
in SettingsServices.tsx where isLidarr is passed (the component invocation that
currently contains isLidarr={true}) and replace that assignment with just
isLidarr to follow idiomatic React boolean prop syntax.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 23c91588-95eb-4192-ae96-b609c143e55a

📥 Commits

Reviewing files that changed from the base of the PR and between 759e359 and 86ad968.

⛔ Files ignored due to path filters (1)
  • src/assets/services/lidarr.svg is excluded by !**/*.svg
📒 Files selected for processing (15)
  • README.md
  • docs/README.md
  • docs/using-seerr/backups.md
  • docs/using-seerr/settings/services.md
  • seerr-api.yml
  • server/api/servarr/lidarr.ts
  • server/lib/cache.ts
  • server/lib/settings/index.ts
  • server/routes/media.ts
  • server/routes/service.ts
  • server/routes/settings/index.ts
  • server/routes/settings/lidarr.ts
  • src/components/Settings/LidarrModal/index.tsx
  • src/components/Settings/SettingsServices.tsx
  • src/i18n/locale/en.json

Comment thread seerr-api.yml Resolved
Comment thread seerr-api.yml Resolved
Comment thread seerr-api.yml Resolved
Comment on lines +338 to +391
public async addAlbum(options: LidarrAlbumOptions): Promise<LidarrAlbum> {
try {
const existingAlbums = await this.get<LidarrAlbum[]>('/album', {
params: {
foreignAlbumId: options.foreignAlbumId,
includeAllArtistAlbums: 'false',
},
});

if (existingAlbums.length > 0 && existingAlbums[0].monitored) {
logger.info(
'Album is already monitored in Lidarr. Skipping add and returning success',
{
label: 'Lidarr',
}
);
return existingAlbums[0];
}

if (existingAlbums.length > 0) {
logger.info(
'Album exists in Lidarr but is not monitored. Updating monitored status.',
{
label: 'Lidarr',
albumId: existingAlbums[0].id,
albumTitle: existingAlbums[0].title,
}
);

const updatedAlbum = await this.axios.put<LidarrAlbum>(
`/album/${existingAlbums[0].id}`,
{
...existingAlbums[0],
monitored: true,
}
);

await this.post('/command', {
name: 'AlbumSearch',
albumIds: [updatedAlbum.data.id],
});

return updatedAlbum.data;
}

const data = await this.post<LidarrAlbum>('/album', {
...options,
monitored: true,
});
return data;
} catch (e) {
throw new Error(`[Lidarr] Failed to add album: ${e.message}`);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect ExternalAPI base to confirm get/post/put/delete signatures, return types, and caching
f=$(fd -i -t f 'externalapi' | head -n1)
echo "File: $f"
rg -nP -C4 '\b(protected|public|private)\s+(async\s+)?(get|post|put|delete)\s*[<(]' "$f"

Repository: seerr-team/seerr

Length of output: 501


Fix stale caching in addAlbum existence check (drop the post return-type concern).

  • ExternalAPI.post<T>() returns response.data, so return data in addAlbum matches Promise<LidarrAlbum> (the return-shape concern doesn’t apply).
  • addAlbum calls this.get('/album', ...) without disabling/bypassing cache (ExternalAPI.get supports a ttl parameter), and this method doesn’t invalidate the cached /album results after the subsequent PUT/POST—so the monitored vs unmonitored branch can misfire due to stale cached data.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/api/servarr/lidarr.ts` around lines 338 - 391, The existence check in
addAlbum uses this.get('/album', ...) which may return stale cached results
because ExternalAPI.get supports a ttl parameter and cache isn’t invalidated
after the subsequent axios.put or this.post; fix by forcing a fresh fetch for
the existence check (call this.get('/album', { params: {...}, ttl: 0 }) or
equivalent to bypass cache) and ensure you invalidate or refresh the album cache
after mutating calls (after axios.put in the monitored-update branch and after
this.post when creating a new album) so future calls see the updated monitored
state; keep the post return handling as-is since ExternalAPI.post<T>() returns
response.data.

Comment thread server/routes/settings/lidarr.ts Resolved
Comment on lines +254 to +256
const profileName = testResponse.profiles.find(
(profile) => profile.id === Number(values.activeProfileId)
)?.name;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add validation for profile and metadata profile name resolution.

At lines 254-256 and 275-278, the code uses .find() to look up profile names by ID. If the profile or metadata profile is not found in testResponse (e.g., it was deleted in Lidarr between testing and saving), the name will be undefined, and the backend will receive an incomplete LidarrSettings object.

According to the backend type definition (context snippet 2), both activeProfileName and activeMetadataProfileName are required string fields.

🛡️ Proposed fix to validate profile resolution
         try {
           const profileName = testResponse.profiles.find(
             (profile) => profile.id === Number(values.activeProfileId)
           )?.name;
+          const metadataProfileName = testResponse.metadataProfiles.find(
+            (profile) => profile.id === Number(values.activeMetadataProfileId)
+          )?.name;

+          if (!profileName || !metadataProfileName) {
+            addToast(
+              'Selected profiles not found. Please test the connection again.',
+              {
+                appearance: 'error',
+                autoDismiss: true,
+              }
+            );
+            return;
+          }

           const submission = {
             name: values.name,
             hostname: values.hostname,
             port: Number(values.port),
             apiKey: values.apiKey,
             useSsl: values.ssl,
             baseUrl: values.baseUrl,
             activeProfileId: Number(values.activeProfileId),
             activeProfileName: profileName,
             activeDirectory: values.rootFolder,
             tags: values.tags,
             isDefault: values.isDefault,
             externalUrl: values.externalUrl,
             syncEnabled: values.syncEnabled,
             preventSearch: !values.enableSearch,
             tagRequests: values.tagRequests,
             activeMetadataProfileId: Number(values.activeMetadataProfileId),
-            activeMetadataProfileName: testResponse.metadataProfiles.find(
-              (profile) =>
-                profile.id === Number(values.activeMetadataProfileId)
-            )?.name,
+            activeMetadataProfileName: metadataProfileName,
           };

Also applies to: 275-278

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Settings/LidarrModal/index.tsx` around lines 254 - 256, The
profile name lookups using testResponse.profiles.find(...) and
testResponse.metadataProfiles.find(...) can return undefined; update the
save/submit logic that constructs LidarrSettings so that after resolving
profileName (from testResponse.profiles and values.activeProfileId) and
metadataProfileName (from testResponse.metadataProfiles and
values.activeMetadataProfileId) you validate both are non-empty strings—if
either lookup returns undefined, surface a clear user error (e.g., set form
error or show toast) and abort the save instead of sending an incomplete object;
ensure activeProfileName and activeMetadataProfileName are only set when the
finds succeed and prevent the submission path that constructs LidarrSettings
until validation passes.

Comment on lines +331 to +333
if (!values.baseUrl || values.baseUrl === '/') {
setFieldValue('baseUrl', testResponse.urlBase);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify the baseUrl auto-fill condition.

The condition if (!values.baseUrl || values.baseUrl === '/') will auto-fill the base URL when it's either empty or set to '/'. However, the validation schema (lines 142-152) requires that baseUrl must not end with a trailing slash, which means '/' would fail validation. This makes the === '/' check unreachable in a valid form state.

Additionally, testResponse.urlBase is optional (line 88), so if it's undefined, this will set baseUrl to undefined, potentially causing validation issues.

Consider simplifying the condition to only check for empty/falsy values:

♻️ Suggested refinement
-                if (!values.baseUrl || values.baseUrl === '/') {
+                if (!values.baseUrl && testResponse.urlBase) {
                   setFieldValue('baseUrl', testResponse.urlBase);
                 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!values.baseUrl || values.baseUrl === '/') {
setFieldValue('baseUrl', testResponse.urlBase);
}
if (!values.baseUrl && testResponse.urlBase) {
setFieldValue('baseUrl', testResponse.urlBase);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Settings/LidarrModal/index.tsx` around lines 331 - 333, The
auto-fill should only run when baseUrl is empty and must not overwrite with
undefined or an invalid '/' value: change the condition on values.baseUrl in the
block that calls setFieldValue('baseUrl', testResponse.urlBase) to only trigger
when values.baseUrl is falsy and testResponse.urlBase is a non-empty string
(e.g. check testResponse.urlBase !== undefined && testResponse.urlBase !== ''),
or otherwise skip setting it; references: values.baseUrl, setFieldValue, and
testResponse.urlBase.

@Crow-Control

Copy link
Copy Markdown
Author

Copilot review feedback response:
All the referenced sections match the radarr/sonarr code-standard.

Doing that differently on Lidarr-only, is a bad practice and makes the codebase less maintainable
Doing so for Radarr and Sonarr as well, is out of scope of this PR

If we want to change said coding standards, it should be in a seperate PR.

Comment thread server/api/servarr/lidarr.ts Dismissed
Comment thread server/api/servarr/lidarr.ts Dismissed
@gauthier-th

Copy link
Copy Markdown
Member

@Crow-Control Instead of targeting develop with your PR, could you target another branch so we merge things one PR at a time? If so, I can create a lidarr branch so we can merge things progressively (and test it as well).
I prefer the way you introduce the PRs (one by one for easier review) but we will not merge something that is not ready into develop.

@Crow-Control

Crow-Control commented Jun 5, 2026 •

Copy link
Copy Markdown
Author

@Crow-Control Instead of targeting develop with your PR, could you target another branch so we merge things one PR at a time? If so, I can create a lidarr branch so we can merge things progressively (and test it as well). I prefer the way you introduce the PRs (one by one for easier review) but we will not merge something that is not ready into develop.

Completely understandable!
Can you make a "music" branch for me to target all the music related PR's towards?

@gauthier-th

Copy link
Copy Markdown
Member

@Crow-Control Instead of targeting develop with your PR, could you target another branch so we merge things one PR at a time? If so, I can create a lidarr branch so we can merge things progressively (and test it as well). I prefer the way you introduce the PRs (one by one for easier review) but we will not merge something that is not ready into develop.

Completely understandable! Can you make a "music" branch for me to target all the music related PR's towards?

Here it is: https://github.com/seerr-team/seerr/tree/music

Feel free to hop on our Discord if you have some question or remarks.

@Crow-Control
Crow-Control changed the base branch from develop to music June 5, 2026 12:21
@gauthier-th gauthier-th mentioned this pull request Jun 5, 2026
2 of 4 tasks
@gauthier-th

Copy link
Copy Markdown
Member

For better clarity, since all you PRs are related to the Lidarr / music implementation, could you please set the same scope (i.e. lidarr or music) for the conventional commit names?

@Crow-Control

Copy link
Copy Markdown
Author

music

good call!

@Crow-Control Crow-Control changed the title feat(lidarr): add Lidarr server settings and connectivity feat(music): add Lidarr server settings and connectivity Jun 5, 2026
Comment thread server/routes/media.ts Resolved
@Crow-Control
Crow-Control marked this pull request as draft June 5, 2026 13:00
@Crow-Control

Copy link
Copy Markdown
Author

Converted to draft, due to restructuring based on modern sonarr/radarr

@Crow-Control
Crow-Control force-pushed the lidarr branch 2 times, most recently from bda7910 to 90f863b Compare June 5, 2026 13:51
@Crow-Control
Crow-Control marked this pull request as ready for review June 5, 2026 13:54
@Crow-Control

Crow-Control commented Jun 5, 2026 •

Copy link
Copy Markdown
Author

@gauthier-th I've done as you asked, at the same time I decreased scope of the API a bit (limiting the PR to match the featureset of the sonarr API) and added a few basic unit tests (Co-authored by Claude) to ensure the basic endpoints at least do something correctly.

I also did an extra AI query to list any changes done that deviate from the sonarr example.
Which returned only the expected area's (considering its a music and not a series thing)

@Crow-Control
Crow-Control requested a review from gauthier-th June 5, 2026 14:01
Comment thread server/api/servarr/lidarr.test.ts Resolved
@seerr-automation-bot seerr-automation-bot added this to the v3.4.0 milestone Jun 8, 2026
@gauthier-th gauthier-th removed this from the v3.4.0 milestone Jun 8, 2026
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.

6 participants