[Bug]: authors.lastFirst is not always populated #2272

Closed
opened 2026-04-25 00:05:40 +02:00 by adam · 4 comments
Owner

Originally created by @pwinnski on GitHub (Sep 23, 2024).

What happened?

Of the 1961 authors in my library, 194 of them do not have a lastFirst set in the database, and so sort oddly.

sqlite> SELECT COUNT(*) FROM authors WHERE lastFirst IS NULL;
194
sqlite> SELECT COUNT(*) FROM authors WHERE lastFirst IS NOT NULL;
1767

I have no idea what sets these authors apart from others although just now as I was planning to copy and paste in some examples to show that they range from L. M. Montgomery to to Andrew Child, I noticed that one was clearly a failed QuickMatch, so I manually cleared out the metadata--and suddenly it had a lastFirst field set. So maybe these are the result of failures when I told it to "Match All Authors" with nearly 2000 authors?

Here's an example of three authors whose first names start with B sorting into the wrong place when sorting by Last, First:
image
It clearly shouldn't be that order and in fact, although I was mostly interesting in missing lastFirst columns, now I'm puzzled about why Asako Uzuki is out of order as well!

sqlite> SELECT name, lastFirst FROM authors WHERE name in ('Ben Wolf', 'Bryan Washington', 'Asako Yuzuki', 'Brianna Wiest', 'Bonnie Wynne', 'Brent Weinbach', 'C Pam Zhang', 'Bernice McFadden', 'Brené Brown') ORDER BY lastFirst;
Brent Weinbach|
Bernice McFadden|
Brené Brown|
Bryan Washington|Washington, Bryan
Brianna Wiest|Wiest, Brianna
Ben Wolf|Wolf, Ben
Bonnie Wynne|Wynne, Bonnie
Asako Yuzuki|Yuzuki, Asako
C Pam Zhang|Zhang, C Pam

Even ignoring the missing lastFirst authors, I still expect: Washington, Wiest, Wolf, Wynne, Yuzuki, Zhang, but I got: Washington, Wolf, Yuzuki, Wiest, Wynne, Zhang.

I just checked from my phone, and the sort order is different there!
IMG_7075
Is that just ignoring "Last, First" and sorting by first name?

What did you expect to happen?

I expect all authors to have a lastFirst set, and for a list of authors sorted by Last, First to sort the authors by Last, First.

Steps to reproduce the issue

  1. Have my library?
  2. Visit the Authors tab, sorted by Last, First.

Audiobookshelf version

v2.13.4

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Other (list in "Additional Notes" box)

If the issue is being seen in the UI, what browsers are you seeing the problem on?

Other (list in "Additional Notes" box)

Logs

No response

Additional Notes

Hosted on Synology via Docker.
I've tested on Arc (Chrome) desktop and iOS browser. Results are different, but both are wrong.

Originally created by @pwinnski on GitHub (Sep 23, 2024). ### What happened? Of the 1961 authors in my library, 194 of them do not have a `lastFirst` set in the database, and so sort oddly. ``` sqlite> SELECT COUNT(*) FROM authors WHERE lastFirst IS NULL; 194 sqlite> SELECT COUNT(*) FROM authors WHERE lastFirst IS NOT NULL; 1767 ``` I have no idea what sets these authors apart from others although just now as I was planning to copy and paste in some examples to show that they range from L. M. Montgomery to to Andrew Child, I noticed that one was clearly a failed QuickMatch, so I manually cleared out the metadata--and suddenly it had a lastFirst field set. So maybe these are the result of failures when I told it to "Match All Authors" with nearly 2000 authors? Here's an example of three authors whose first names start with B sorting into the wrong place when sorting by Last, First: ![image](https://github.com/user-attachments/assets/d1bf5cc3-ae69-4239-ac31-e2a49cd6ab96) It clearly shouldn't be that order and in fact, although I was mostly interesting in missing lastFirst columns, now I'm puzzled about why Asako Uzuki is out of order as well! ``` sqlite> SELECT name, lastFirst FROM authors WHERE name in ('Ben Wolf', 'Bryan Washington', 'Asako Yuzuki', 'Brianna Wiest', 'Bonnie Wynne', 'Brent Weinbach', 'C Pam Zhang', 'Bernice McFadden', 'Brené Brown') ORDER BY lastFirst; Brent Weinbach| Bernice McFadden| Brené Brown| Bryan Washington|Washington, Bryan Brianna Wiest|Wiest, Brianna Ben Wolf|Wolf, Ben Bonnie Wynne|Wynne, Bonnie Asako Yuzuki|Yuzuki, Asako C Pam Zhang|Zhang, C Pam ``` Even ignoring the missing lastFirst authors, I still expect: Washington, Wiest, Wolf, Wynne, Yuzuki, Zhang, but I got: Washington, Wolf, Yuzuki, Wiest, Wynne, Zhang. I just checked from my phone, and the sort order is different there! ![IMG_7075](https://github.com/user-attachments/assets/267ec0b2-4ca6-4bd2-b0f7-48301d2b436b) Is that just ignoring "Last, First" and sorting by first name? ### What did you expect to happen? I expect all authors to have a lastFirst set, and for a list of authors sorted by Last, First to sort the authors by Last, First. ### Steps to reproduce the issue 1. Have my library? 2. Visit the Authors tab, sorted by Last, First. ### Audiobookshelf version v2.13.4 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Other (list in "Additional Notes" box) ### If the issue is being seen in the UI, what browsers are you seeing the problem on? Other (list in "Additional Notes" box) ### Logs _No response_ ### Additional Notes Hosted on Synology via Docker. I've tested on Arc (Chrome) desktop and iOS browser. Results are different, but both are wrong.
adam added the bug label 2026-04-25 00:05:40 +02:00
adam closed this issue 2026-04-25 00:05:40 +02:00
Author
Owner

@nichwall commented on GitHub (Sep 23, 2024):

Duplicate of https://github.com/advplyr/audiobookshelf/issues/2385

@nichwall commented on GitHub (Sep 23, 2024): Duplicate of https://github.com/advplyr/audiobookshelf/issues/2385
Author
Owner

@pwinnski commented on GitHub (Sep 23, 2024):

I note that there was a related fix in v2.13.2, for the lastFirst part of this. I will manually update the 193 remaining affected authors to get lastFirst updated everywhere, and hope that resolves the sorting issues as well. I'll update this issue with my results.

@pwinnski commented on GitHub (Sep 23, 2024): I note that there was a related fix in v2.13.2, for the lastFirst part of this. I will manually update the 193 remaining affected authors to get lastFirst updated everywhere, and hope that resolves the sorting issues as well. I'll update this issue with my results.
Author
Owner

@pwinnski commented on GitHub (Sep 23, 2024):

I'm down to 108 authors with a null lastFirst, but already I've seen what happens with the very-odd sorting.

When I view authors by Last, First, initially I see all authors sorted from 'Aaronovich, Ben' to 'Žižek, Slavoj,' after which I get the 108 authors with a null lastFirst sorted by first name from 'Aaron M. Glazer' to 'Wayétu Moore.'

BUT then I clicked onto one of the authors, to see what books I have by that author, and when I then hit 'back,' everything had changed! Now things don't sort right at all. When I view authors by Last, First, I still see 'Aaronovich' first, but the last could be 'Zhang Zhou' or 'Tony Zinni,' or I guess some other author whose last name starts with 'Z'. The authors who belong there are scattered around the listing in what seems to be a deterministic but odd order, usually among authors where first names sort correctly.

I guess technically that's a different bug than I started reporting, but I'll finish updating authors to see if this behavior goes away once I have lastFirst populated for everyone.

@pwinnski commented on GitHub (Sep 23, 2024): I'm down to 108 authors with a null lastFirst, but already I've seen what happens with the very-odd sorting. When I view authors by Last, First, initially I see all authors sorted from 'Aaronovich, Ben' to 'Žižek, Slavoj,' after which I get the 108 authors with a null lastFirst sorted by first name from 'Aaron M. Glazer' to 'Wayétu Moore.' BUT then I clicked onto one of the authors, to see what books I have by that author, and when I then hit 'back,' everything had changed! Now things don't sort right at all. When I view authors by Last, First, I still see 'Aaronovich' first, but the last could be 'Zhang Zhou' or 'Tony Zinni,' or I guess some other author whose last name starts with 'Z'. The authors who belong there are scattered around the listing in what seems to be a deterministic but odd order, usually among authors where first names sort correctly. I guess technically that's a different bug than I started reporting, but I'll finish updating authors to see if this behavior goes away once I have lastFirst populated for everyone.
Author
Owner

@pwinnski commented on GitHub (Sep 23, 2024):

Once the NULL lastFirst issues were resolved, the sorting issues went away as well.
I handled the first hundred or so manually through the UI during boring meetings, but then work was over and I focused on automating this. Rather than right something elaborate, I looked at the list and eyeballed the edge cases, updating those manually in the ABS UI as well, and once the list was only straightforward "the last word in this string is the last name" names, I used a SQL UPDATE to set those and restarted ABS.

All is well in authorville! Thanks for the fix in v2.13.2!

@pwinnski commented on GitHub (Sep 23, 2024): Once the NULL lastFirst issues were resolved, the sorting issues went away as well. I handled the first hundred or so manually through the UI during boring meetings, but then work was over and I focused on automating this. Rather than right something elaborate, I looked at the list and eyeballed the edge cases, updating those manually in the ABS UI as well, and once the list was only straightforward "the last word in this string is the last name" names, I used a SQL UPDATE to set those and restarted ABS. All is well in authorville! Thanks for the fix in v2.13.2!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2272