[Bug] Some authors have lastFirst set to null #1577

Open
opened 2026-04-24 23:50:33 +02:00 by adam · 8 comments
Owner

Originally created by @nichwall on GitHub (Dec 4, 2023).

Describe the issue

(reported in Discord)

Some authors do not have lastFirst set, causing authors to be sorted incorrectly. This can also cause duplicate authors to appear. (https://discord.com/channels/942908292873723984/942914154254176257/1181034467087876166)

image-1

This may also be what is causing duplicate authors in other languages (https://discord.com/channels/942908292873723984/942908295579062335/1179099817088135188)
Screenshot_2023-11-28_at_9 40 17_AM

Steps to reproduce the issue

  1. Not sure. Reporter has been running on 2.3.3 and attempted upgrades to new releases when they come out (2.4.x through 2.6.0) before reverting to 2.3.3 due to performance bugs and some things not being sorted (authors).
  2. May be missing a migration step for this column.

Audiobookshelf version

2.3.3, 2.4.x, 2.5.0, 2.6.0

How are you running audiobookshelf?

Docker

Originally created by @nichwall on GitHub (Dec 4, 2023). ### Describe the issue (reported in Discord) Some authors do not have `lastFirst` set, causing authors to be sorted incorrectly. This can also cause duplicate authors to appear. (https://discord.com/channels/942908292873723984/942914154254176257/1181034467087876166) ![image-1](https://github.com/advplyr/audiobookshelf/assets/5686638/262039cb-488b-4701-99a0-6832f3593e2c) This may also be what is causing duplicate authors in other languages (https://discord.com/channels/942908292873723984/942908295579062335/1179099817088135188) <img width="745" alt="Screenshot_2023-11-28_at_9 40 17_AM" src="https://github.com/advplyr/audiobookshelf/assets/5686638/adb702f7-dccf-4799-993b-a2a1ab85e92c"> ### Steps to reproduce the issue 1. Not sure. Reporter has been running on `2.3.3` and attempted upgrades to new releases when they come out (`2.4.x` through `2.6.0`) before reverting to `2.3.3` due to performance bugs and some things not being sorted (authors). 2. May be missing a migration step for this column. ### Audiobookshelf version `2.3.3`, `2.4.x`, `2.5.0`, `2.6.0` ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:50:33 +02:00
Author
Owner

@nichwall commented on GitHub (Dec 4, 2023):

This may have been introduced before 2.5.0 and not really noticed until 2.5.0 because of changes regarding whether authors without books are displayed or not (and admin vs regular user views). Prior to that the main symptom would have been sorting out of order.

@nichwall commented on GitHub (Dec 4, 2023): This may have been introduced before `2.5.0` and not really noticed until `2.5.0` because of changes regarding whether authors without books are displayed or not (and admin vs regular user views). Prior to that the main symptom would have been sorting out of order.
Author
Owner

@advplyr commented on GitHub (Dec 4, 2023):

I don't think the duplicate authors has to do with the lastFirst issue but maybe I'm missing something

@advplyr commented on GitHub (Dec 4, 2023): I don't think the duplicate authors has to do with the `lastFirst` issue but maybe I'm missing something
Author
Owner

@nichwall commented on GitHub (Dec 4, 2023):

It may not be related, I was just documenting the issue where the column isn't populated and thought to add it in case others notice duplicates as well. I feel like it's been mentioned a few times lately but I can't remember who/when/where.

@nichwall commented on GitHub (Dec 4, 2023): It may not be related, I was just documenting the issue where the column isn't populated and thought to add it in case others notice duplicates as well. I feel like it's been mentioned a few times lately but I can't remember who/when/where.
Author
Owner

@nichwall commented on GitHub (Dec 5, 2023):

What may have happened is the lastFirst column did not exist in 2.3.3, but did exist in 2.4.3 (I haven't gone through all of the 2.4.x, those were just two servers I already had set up when I looked at their databases).

We recommended rolling back to 2.3.3 without needing to restore from a backup because new columns were added in 2.4.x but weren't used in 2.3.3 and that simplified the "test out the new version" for users. So, if a user upgraded and decided they wanted to roll back to 2.3.3, the column would exist on the 2.3.3 version but not be populated by new entries, and then not migrated when upgrading again since the column already existed. I think, not 100% sure on how the migration works.

This might explain why authors added in 2.3.3 for UndeadWookie had sorting issues after upgrading (since they rolled back to 2.3.3). I am leaning towards this also causing duplicate authors because of adding Defiant by Brandon Sanderson (on 2.3.3) caused a duplicate author because the "real" Sanderson had the lastFirst column filled, but the "new" did not, causing a duplicate.

It may be worth adding a check for all Null fields (that shouldn't be Null) in the database during startup just to make sure everything is populated. Not sure if that would handle duplicates.

@nichwall commented on GitHub (Dec 5, 2023): What may have happened is the `lastFirst` column did not exist in `2.3.3`, but did exist in `2.4.3` (I haven't gone through all of the `2.4.x`, those were just two servers I already had set up when I looked at their databases). We recommended rolling back to `2.3.3` without needing to restore from a backup because new columns were added in `2.4.x` but weren't used in `2.3.3` and that simplified the "test out the new version" for users. So, if a user upgraded and decided they wanted to roll back to `2.3.3`, the column would exist on the `2.3.3` version but not be populated by new entries, and then not migrated when upgrading again since the column already existed. I think, not 100% sure on how the migration works. This might explain why authors added in `2.3.3` for UndeadWookie had sorting issues after upgrading (since they rolled back to `2.3.3`). I am leaning towards this also causing duplicate authors because of adding Defiant by Brandon Sanderson (on `2.3.3`) caused a duplicate author because the "real" Sanderson had the `lastFirst` column filled, but the "new" did not, causing a duplicate. It may be worth adding a check for all Null fields (that shouldn't be Null) in the database during startup just to make sure everything is populated. Not sure if that would handle duplicates.
Author
Owner

@nichwall commented on GitHub (Dec 5, 2023):

After further Discord discussion, it's probably not causing the duplicate authors, and isn't true for every book/author/series added in 2.3.3 so there may be someone else going on.

@nichwall commented on GitHub (Dec 5, 2023): After further Discord discussion, it's probably not causing the duplicate authors, and isn't true for every book/author/series added in `2.3.3` so there may be someone else going on.
Author
Owner

@Hallo951 commented on GitHub (Dec 6, 2023):

I had the same problem. In my case, the error was caused by the new scanner settings. For test purposes, I had set the "folder structure" to the highest priority and rescanned my database. As a result, the authors in all audiobooks for which the folder structure did not match the author stored in the metafile were overwritten with the information from the folder structure. For example, if I have various audiobooks written by several authors in the "Multible Authors" folder, the correct authors are replaced by the name "Multible Authors" in the "Folder Structure" scanner setting. In this case, however, the correct/original author portraits with 0 books remain on the author page. The same phenomenon occurs if the top folder name of an audiobook, which represents the author name, differs from the author name stored in the database for the same audiobook (e.g. due to a space). If this is the case, a new author is created on the authors' overview page and you have two authors who appear identical but are actually different.

@Hallo951 commented on GitHub (Dec 6, 2023): I had the same problem. In my case, the error was caused by the new scanner settings. For test purposes, I had set the "folder structure" to the highest priority and rescanned my database. As a result, the authors in all audiobooks for which the folder structure did not match the author stored in the metafile were overwritten with the information from the folder structure. For example, if I have various audiobooks written by several authors in the "Multible Authors" folder, the correct authors are replaced by the name "Multible Authors" in the "Folder Structure" scanner setting. In this case, however, the correct/original author portraits with 0 books remain on the author page. The same phenomenon occurs if the top folder name of an audiobook, which represents the author name, differs from the author name stored in the database for the same audiobook (e.g. due to a space). If this is the case, a new author is created on the authors' overview page and you have two authors who appear identical but are actually different.
Author
Owner

@nichwall commented on GitHub (Feb 3, 2024):

I think I found the problem. The migrationPatch2 function skips the migration if the columns already exist, so if a user rolls back to a previous version then it will skip this part of the update.

https://github.com/advplyr/audiobookshelf/blob/432e25565e9a4aca43d9c3194f7babe89eb6206b/server/utils/migrations/dbMigration.js#L1627-L1630

@nichwall commented on GitHub (Feb 3, 2024): I think I found the problem. The `migrationPatch2` function skips the migration if the columns already exist, so if a user rolls back to a previous version then it will skip this part of the update. https://github.com/advplyr/audiobookshelf/blob/432e25565e9a4aca43d9c3194f7babe89eb6206b/server/utils/migrations/dbMigration.js#L1627-L1630
Author
Owner

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

I installed this very recently, so recently that right now I'm cursing github's use of "3 weeks ago" in lieu of actual useful dates. I genuinely can't figure out if I started with v2.13.1 or v2.13.2, but I installed whatever the "latest" docker tag pointed to on 2024-08-31.

Oh yes! The docker registry is MUCH better, when you hover over "3 weeks ago" it gives you a date and time. So I started with v2.13.0, no migrationPath2 for me.

I do note there's been a fix related to this very issue in v2.13.2, in this commit: https://github.com/advplyr/audiobookshelf/commit/db86bfd63d7011fdd1323d5a9c8325861f1b65b2

@pwinnski commented on GitHub (Sep 23, 2024): I installed this very recently, so recently that right now I'm cursing github's use of "3 weeks ago" in lieu of actual useful dates. I genuinely can't figure out if I started with v2.13.1 or v2.13.2, but I installed whatever the "latest" docker tag pointed to on 2024-08-31. Oh yes! The docker registry is MUCH better, when you hover over "3 weeks ago" it gives you a date and time. So I started with v2.13.0, no migrationPath2 for me. I do note there's been a fix related to this very issue in v2.13.2, in this commit: https://github.com/advplyr/audiobookshelf/commit/db86bfd63d7011fdd1323d5a9c8325861f1b65b2
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1577