Skip to content

Add health check for root folders missing media type defaults - #85

Open
jbob06 wants to merge 1 commit into
Chaptarr:developfrom
jbob06:fix/rootfolder-missing-media-type-defaults
Open

Add health check for root folders missing media type defaults#85
jbob06 wants to merge 1 commit into
Chaptarr:developfrom
jbob06:fix/rootfolder-missing-media-type-defaults

Conversation

@jbob06

@jbob06 jbob06 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

Fixes #31.

POST /api/v1/rootfolder lets you create a root folder with no AudiobookSettings/EbookSettings (or with settings that have no quality/metadata profile chosen) configured for a media type its FolderType accepts. When DiscoveryWorker later tries to auto-create an author/book there, AuthorLibraryService.NormalizeMonitoringConfigForMediaType throws - but that's a warn-level log entry deep in an async import path with no retry and no other visible surfacing, so the failure is invisible outside manually paging through /api/v1/log.

This adds RootFolderMediaTypeDefaultsCheck, a health check that flags any root folder missing usable defaults for a media type its FolderType is compatible with, so the gap shows up in the UI's health/system status instead. It mirrors NormalizeMonitoringConfigForMediaType's own checks (settings present, quality profile id set, metadata profile id set) so it can't report healthy while that method is still failing for the same root folder. It's wired with [CheckOn(typeof(ModelEvent<RootFolder>))] (same pattern as CalibreRootFolderCheck/DownloadClientRootFolderCheck) so it re-evaluates immediately on root folder create/update/delete, plus the usual startup/scheduled runs.

Known gap, left out of this pass: it doesn't detect a quality/metadata profile id that points at a since-deleted profile (the other thing NormalizeMonitoringConfigForMediaType validates) - that needs IQualityProfileService/IMetadataProfileService injected and felt like a separate, slightly bigger change. Happy to add it here if preferred.

Deliberately did not touch DiscoveryWorker's async retry path or add blocking validation to POST /api/v1/rootfolder itself, to keep this additive and low-risk rather than changing existing create/update behavior.

Test plan

  • New unit tests in RootFolderMediaTypeDefaultsCheckFixture (9 cases: healthy mixed folder, missing audiobook/ebook settings, single-type folders correctly ignoring the incompatible media type, missing quality/metadata profile ids, corrupt stored settings JSON, multi-folder combined message)
  • Full existing test suite passes unchanged (2861/2861)

A root folder created via POST /api/v1/rootfolder without going through
the UI wizard can be saved with no AudiobookSettings/EbookSettings for
a media type its FolderType accepts. DiscoveryWorker then fails every
author it tries to create there
(AuthorLibraryService.NormalizeMonitoringConfigForMediaType), but the
failure is only a warn-level log entry that's never surfaced elsewhere
and never retried.

Add RootFolderMediaTypeDefaultsCheck, a startup/scheduled health check
that flags any root folder missing defaults for a media type its
FolderType is compatible with, so the gap is visible in the UI instead
of requiring a manual trawl through /api/v1/log.

Fixes Chaptarr#31
@jbob06
jbob06 requested a review from robertlordhood as a code owner August 26, 2026 16:25
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.

POST /api/v1/rootfolder allows creating a root folder with no audiobook/ebook monitor defaults, causing silent DiscoveryWorker failures

1 participant