mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 21:00:09 +00:00
Add guard for empty ASIN in audiobook matcher
Prevents empty ASIN values from matching all library books by adding an early return in findPlexMatch(). Updates documentation to describe the critical bug, its impact, and the implemented fix. This resolves a major issue where AI recommendations were incorrectly filtered out due to empty ASINs matching every record.
This commit is contained in:
@@ -41,6 +41,25 @@ export interface AudiobookMatchResult {
|
||||
export async function findPlexMatch(
|
||||
audiobook: AudiobookMatchInput
|
||||
): Promise<AudiobookMatchResult | null> {
|
||||
// Early return if no ASIN provided (prevents empty string matching all records)
|
||||
if (!audiobook.asin || audiobook.asin.trim() === '') {
|
||||
logger.debug('Matcher result', {
|
||||
MATCHER: {
|
||||
input: {
|
||||
title: audiobook.title,
|
||||
author: audiobook.author,
|
||||
narrator: audiobook.narrator || null,
|
||||
asin: audiobook.asin,
|
||||
},
|
||||
candidatesFound: 0,
|
||||
matchType: 'no_asin_provided',
|
||||
matched: false,
|
||||
result: null,
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
// Query plex_library directly by ASIN (indexed O(1) lookup)
|
||||
// Check both dedicated asin field and plexGuid for backward compatibility
|
||||
const plexBooks = await prisma.plexLibrary.findMany({
|
||||
|
||||
Reference in New Issue
Block a user