Fixes #1210.
Disclosure: drafted with Claude Code at my direction; I read the cited code at the stated commit and reviewed this before posting.
Problem
Books added by series or author monitoring are stored with an ASIN identifier whose Region is null. The Broken books group then lists them as missing a region, and Rescan metadata cannot choose an Audible catalogue for them. A book added by hand keeps its region (read at dc14be0, v1.10.6).
Cause
MapToMetadata in SeriesMonitoringService.Mapping.cs and AuthorMonitoringService.Mapping.cs builds the AudibleBookMetadata without a Region. LibraryAddService passes metadata.Region to SyncImportedIdentifiersFromLegacyFields, which stores NormalizeRegion(null), so the identifier gets a null region.
Change
MapToMetadatatakes the region and sets it on the metadata. Both call sites pass the monitor's region, which is the one the catalogue was fetched with and is always set on a monitor.- Four production lines in four files, plus two tests.
Not changed
- Rows already stored with a null region are not repaired by this change. No migration is included. A one-off backfill from the matching monitor's region is possible and I can propose it separately if wanted.
- Two other paths call the identifier sync without a region and are left alone: the fallback
LibraryAddWorkflow.AddCoreAsync(used only when no add service is registered) andLibraryUpdateWorkflow.Metadata.cson a legacy-field edit.
Evidence
- Read:
MapToMetadatahas exactly two call sites, both updated. The monitor region is a non-null string defaulting to "us". - Measured: two new tests,
MonitorSeriesAsync_StoresAddedBookAsinWithTheRegionOfTheMonitor(real add service and repository, region "uk", reads the stored ASIN identifier back) andMonitorAuthorAsync_PassesTheRegionOfTheMonitorToTheAddedBook. With the production change reverted both fail (expected "uk", got null); with i...
Automated Canary build