Repository navigation
feat(music): add Lidarr server settings and connectivity - #3109
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughSeerr 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. ChangesLidarr Music Library Integration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 winReturn correct status codes in delete-file catch path.
This catch still returns
404 Media not foundfor every failure, including Radarr/Sonarr/TMDB errors andTVDB 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 valueSimplify boolean prop assignment.
The explicit
isLidarr={true}assignment can be simplified to justisLidarrsince 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 winDuplicate method:
searchAlbumandsearchAlbumByMusicBrainzIdare identical.Both methods issue the exact same
GET /searchwithterm: 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 searchAlbumByMusicBrainzIdThen update callers of
searchAlbumto usesearchAlbumByMusicBrainzId.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 valueOptional: parallelize the independent Lidarr lookups.
getProfiles,getMetadataProfiles,getRootFolders, andgetTagsare independent and currently run sequentially. Running them withPromise.allwould reduce the/testround-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 valueEnsure consistent error response/logging for
lidarr.getProfiles()In Express 5, a rejected promise/throw from this
asynchandler is automatically forwarded to the error-handling middleware, so it shouldn’t crash the process. However, this path may not produce the samelogger.error+Failed to connect to Lidarrbehavior as the/testhandler—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
⛔ Files ignored due to path filters (1)
src/assets/services/lidarr.svgis excluded by!**/*.svg
📒 Files selected for processing (15)
README.mddocs/README.mddocs/using-seerr/backups.mddocs/using-seerr/settings/services.mdseerr-api.ymlserver/api/servarr/lidarr.tsserver/lib/cache.tsserver/lib/settings/index.tsserver/routes/media.tsserver/routes/service.tsserver/routes/settings/index.tsserver/routes/settings/lidarr.tssrc/components/Settings/LidarrModal/index.tsxsrc/components/Settings/SettingsServices.tsxsrc/i18n/locale/en.json
| 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}`); | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 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>()returnsresponse.data, soreturn datainaddAlbummatchesPromise<LidarrAlbum>(the return-shape concern doesn’t apply).addAlbumcallsthis.get('/album', ...)without disabling/bypassing cache (ExternalAPI.get supports attlparameter), and this method doesn’t invalidate the cached/albumresults 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.
| const profileName = testResponse.profiles.find( | ||
| (profile) => profile.id === Number(values.activeProfileId) | ||
| )?.name; |
There was a problem hiding this comment.
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.
| if (!values.baseUrl || values.baseUrl === '/') { | ||
| setFieldValue('baseUrl', testResponse.urlBase); | ||
| } |
There was a problem hiding this comment.
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.
| 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.
|
Copilot review feedback response: Doing that differently on Lidarr-only, is a bad practice and makes the codebase less maintainable If we want to change said coding standards, it should be in a seperate PR. |
|
@Crow-Control Instead of targeting |
Completely understandable! |
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. |
|
For better clarity, since all you PRs are related to the Lidarr / music implementation, could you please set the same scope (i.e. |
good call! |
|
Converted to draft, due to restructuring based on modern sonarr/radarr |
bda7910 to
90f863b
Compare
|
@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. |
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:
How Has This Been Tested?
Screenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit
New Features
Documentation
UI