From 9fa67289fe9d7cd84af47d9794c4fd055124965b Mon Sep 17 00:00:00 2001 From: Anai-Guo Date: Sun, 13 Sep 2026 12:12:46 -0700 Subject: [PATCH] Handle NULL author_sort in order_authors books.author_sort is nullable in Calibre's schema; a single book with a NULL value made every book list page return HTTP 500. Fall back to the unsorted author list instead of calling .split() on None. Fixes #3702 Co-Authored-By: Claude Opus 5 (1M context) --- cps/db.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cps/db.py b/cps/db.py index 92e6380ed..a06fb4f97 100644 --- a/cps/db.py +++ b/cps/db.py @@ -908,11 +908,13 @@ class CalibreDB: def order_authors(self, entries, list_return=False, combined=False): for entry in entries: if combined: - sort_authors = entry.Books.author_sort.split('&') + author_sort = entry.Books.author_sort authors_list = entry.Books.authors else: - sort_authors = entry.author_sort.split('&') + author_sort = entry.author_sort authors_list = entry.authors + # author_sort is nullable in Calibre's schema, fall back to the unsorted author list + sort_authors = author_sort.split('&') if author_sort else [] # Create dictionary for O(1) lookup instead of nested loops authors_by_sort = {}