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) <noreply@anthropic.com>
This commit is contained in:
Anai-Guo
2026-09-13 12:12:46 -07:00
co-authored by Claude Opus 5
parent a97826402f
commit 9fa67289fe
+4 -2
View File
@@ -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 = {}