From c814a84b274542ed33b8d29732f416de962198ab Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Wed, 13 May 2026 14:16:30 -0700 Subject: [PATCH] Add logging when author normalization is empty --- server/models/Book.js | 5 ++++- server/scanner/BookScanner.js | 4 ++++ server/scanner/Scanner.js | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/models/Book.js b/server/models/Book.js index d61ec3a46..5c0fc10d4 100644 --- a/server/models/Book.js +++ b/server/models/Book.js @@ -480,7 +480,10 @@ class Book extends Model { const authorsAdded = [] for (const authorName of newAuthorNames) { const { author, created } = await authorModel.findOrCreateByNameAndLibrary(authorName, libraryId) - if (!author) continue + if (!author) { + Logger.warn(`[Book] "${this.title}" skipped author "${authorName}" because normalized name was empty`) + continue + } await bookAuthorModel.create({ bookId: this.id, authorId: author.id }) if (created) { SocketAuthority.emitter('author_added', author.toOldJSON()) diff --git a/server/scanner/BookScanner.js b/server/scanner/BookScanner.js index 005b0f0e7..42068c7e6 100644 --- a/server/scanner/BookScanner.js +++ b/server/scanner/BookScanner.js @@ -223,6 +223,10 @@ class BookScanner { for (const authorName of bookMetadata.authors) { if (!media.authors.some((au) => Database.authorModel.isAuthorNameMatch(au.name, authorName))) { const { author, created } = await Database.authorModel.findOrCreateByNameAndLibrary(authorName, libraryItemData.libraryId) + if (!author) { + libraryScan.addLog(LogLevel.WARN, `Skipping author "${authorName}" because normalized name was empty`) + continue + } if (!created) { await Database.bookAuthorModel.create({ bookId: media.id, diff --git a/server/scanner/Scanner.js b/server/scanner/Scanner.js index ec466300d..a4125e9ec 100644 --- a/server/scanner/Scanner.js +++ b/server/scanner/Scanner.js @@ -250,7 +250,10 @@ class Scanner { const existingAuthor = libraryItem.media.authors.find((a) => Database.authorModel.isAuthorNameMatch(a.name, authorName)) if (!existingAuthor) { const { author, created: isCreated } = await Database.authorModel.findOrCreateByNameAndLibrary(authorName, libraryItem.libraryId) - if (!author) continue + if (!author) { + libraryScan.addLog(LogLevel.WARN, `Skipping author "${authorName}" because normalized name was empty`) + continue + } if (isCreated) { SocketAuthority.emitter('author_added', author.toOldJSON()) // Update filter data