[BUG] Import matches a sibling book when the file title carries a subtitle the edition title lacks

Aperta
#262 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #291 di @Arthur031221 — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
csharp, postgresql
Ambito
backend, databases

Direzione di ricerca

Start in FileMatchingService and inspect the strict edition eligibility pass, the CONTAINMENT_FAILED rejection, and the leftover fallback that excludes stagedPreferredBookIds. The report says Stage 2 selects book 6598 and edition 16318 carries the matching ASIN; compare the two dc:title variants in the reproduction against that path. Done means the subtitle variant selects book 6598, with a regression test covering both titles. An open linked pull request (#291) already addresses this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Version: 0.9.965.0 (Docker, chaptarr/chaptarr:develop, buildTime 2026-09-27T18:51:06Z), PostgreSQL backend

What happens

A book file whose embedded title carries a subtitle that its own edition title does not have fails the strict edition-eligibility pass with CONTAINMENT_FAILED. The fallback that runs next re-scores with !stagedPreferredBookIds.Contains(...), so the book Stage 2 already identified is excluded by construction — and the only candidate that passes containment is the edition titled exactly the bare series name. That edition wins.

Concretely: "The Primal Hunter 6" imports as "The Primal Hunter, Vol. 1". Book 6, edition 16318 (ASIN B0BW17HMDZ), resolves to book 6589 — the series' volume 1.

To reproduce

The trigger is the subtitle, not the series number. Take the same file and change only dc:title in its OPF:

dc:title in the epub Matched book
The Primal Hunter 6 The Primal Hunter 6 — correct
The Primal Hunter 6: A LitRPG Adventure The Primal Hunter, Vol. 1 — wrong
The Primal Hunter The Primal Hunter, Vol. 1

Same file, same ASIN, same tags otherwise. Nothing but the title string differs between rows 1 and 2.

Steps:

  1. GET /api/v1/manualimport?folder=<folder>&filterExistingFiles=false on the file titled The Primal Hunter 6: A LitRPG Adventure.
  2. Response suggests "The Primal Hunter, Vol. 1" with rejections: [].
  3. Edit dc:title to The Primal Hunter 6, re-zip, repeat. Response suggests "The Primal Hunter 6".

For the A/B I built NzbDrone.MatchBench and ran /libraryaudit /live=true /source=disk against a directory holding the variants, then compared match_selected per file.

What the trace shows

[STAGED-FTS-FALLBACK] Stage 2 selected provider Book 'Ebook|base:hc:1093426',
but none of its Editions passed eligibility; running deep analysis on the
remaining author-gated Books.
MATCH ACCEPTED (book-occurrence-edition-selection-leftover): EditionId=16309, Title='The Primal Hunter'

Stage 2 gets it right — hc:1093426 is the correct book (local id 6598), with fts_stage2_book_selected reporting localBookIds: 6598, titleFields: title[0], yearExact: true, and the edition's provider keys az:B0BW17HMDZ,hc:edition:31229956. The exact ASIN is right there in the file.

The strict pass then rejects that very edition:

candidate_rejected  ed=16318 book=6598  reason=CONTAINMENT_FAILED

21 of the 22 candidates were rejected with CONTAINMENT_FAILED. The sole survivor was edition 16309, titled exactly The Primal Hunter. So the fallback picks it, and the winning provenance records the series digit as neutral:

[ 0,17] 'The Primal Hunter'   supporting   title      edition
[18,19] '6'                   neutral      tolerated_metadata

Expected behavior

A file whose title contains its own edition title as a prefix should match that edition. At minimum, this shouldn't come back as a clean success with no rejections — see #105.

Diagnostics gap (may be worth fixing on its own)

The rejection reason is invisible in production. IFileMatchingService.TraceSink is assigned only in HolyGrailSmokeTestFixture and NzbDrone.MatchBench, so every RecordCandidateRejection call — gate name, leftovers, reason — writes to a sink that doesn't exist at runtime. No log level exposes it; two Trace-level captures of this exact match produced zero rejection lines. I only got CONTAINMENT_FAILED by building MatchBench.

Additional context

  • Related but distinct from #111: that's duplicate book rows hijacking the monitored row via intersecting work IDs. This author's rows are a different mechanism, and the wrong match here happens inside FileMatchingService containment, not the retarget path.
  • #105 is the reporting side of this: the wrong match is returned with rejections: [] and no confidence, so it's indistinguishable from a correct one. This is one concrete mechanism behind it.
  • The leftover symptom is the importBlocked queue record (#50, #236): grabbed for book 6598, import matched 6589, and it stays there.
  • Across this library, 65 DownloadImportIncomplete events over 31 books with repeated grabs of the same book are consistent with this path.

Uncertainty: I haven't pinned the exact predicate inside containment that yields no evidence when the field value has extra trailing tokens. The interior-gap check in TitleTokenAlignment.TryAlignStructural (lines 88–98) looks like it should pass for [the, primal, hunter, 6] against [the, primal, hunter, 6, a, litrpg, adventure], so something upstream of it is dropping the evidence. The A/B above should locate it quickly.

Logs

Matcher trace from the repro (MatchBench /libraryaudit):

[FILE-GROUP] Embedded tags used (14 keys): all_authors, author, authors, calibre:timestamp, calibre:title_sort, contributor_bkp, cover, creator_aut, date, identifier_unknown
Staged FTS retained 20/20 recalled Books after 1 unique author evaluations and ranked 22 Editions from 6 residual fields
Got 22 FTS results, validating evidence and leftovers...
[STAGED-FTS-FALLBACK] Stage 2 selected provider Book 'Ebook|base:hc:1093426', but none of its Editions passed eligibility; running deep analysis on the remaining author-gated Books.
MATCH ACCEPTED (book-occurrence-edition-selection-leftover): EditionId=16309, Title='The Primal Hunter'
SUCCESS: bk=6589 'The Primal Hunter, Vol. 1' ed=16309 author='Zogarth'

The book is not truncated by the recall limit — I re-ran the stage-1 recall SQL directly against Postgres and it ranks #10 of 23 with the 6 token and #17 without it, against a limit of 20.

Lingua principale
C#
Stelle
664
Fork
48
Merge medio
5h 24m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Chaptarr/chaptarr

Tutte le issue di Chaptarr/chaptarr

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.