[PR #4206] [MERGED] Fix silently ignored errors in password migration seeder #5626

Closed
opened 2026-10-31 20:48:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4206
Author: @hobostay
Created: 5/10/2026
Status: ✅ Merged
Merged: 5/10/2026
Merged by: @MHSanaei

Base: main ← Head: fix/db-seeder-ignored-errors


📝 Commits (1)

  • 72d1310 Fix silently ignored errors in password migration seeder

📊 Changes

1 file changed (+12 additions, -3 deletions)

View changed files

📝 database/db.go (+12 -3)

📄 Description

Summary

  • Fix three silently ignored database errors in database/db.go runSeeders() function
  • The password migration seeder (which migrates user passwords to bcrypt) had three GORM operations whose errors were not checked

Issues Fixed

  1. Pluck("seeder_name", &seedersHistory) — If this fails, seedersHistory is empty, causing the seeder to re-run and potentially double-hash already bcrypt'd passwords, corrupting them and locking users out.

  2. Find(&users) — If this fails, the users slice is empty, so no passwords get migrated, but the seeder still marks itself as complete. Users remain with old-format passwords indefinitely.

  3. Update("password", hashedPassword) — If this fails for any user, their password silently remains in the old format while other users are migrated, creating an inconsistent state.

All three now properly check errors and return early with descriptive log messages.

Test plan

  • Verify the application starts normally with an existing database
  • Verify fresh installation still creates default admin user
  • Verify password migration from old format to bcrypt works correctly
  • Verify that a database error during migration is properly logged and does not mark the seeder as complete

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/4206 **Author:** [@hobostay](https://github.com/hobostay) **Created:** 5/10/2026 **Status:** ✅ Merged **Merged:** 5/10/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/db-seeder-ignored-errors` --- ### 📝 Commits (1) - [`72d1310`](https://github.com/MHSanaei/3x-ui/commit/72d131081a98456e315c3ba1df71673f57e0164e) Fix silently ignored errors in password migration seeder ### 📊 Changes **1 file changed** (+12 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `database/db.go` (+12 -3) </details> ### 📄 Description ## Summary - Fix three silently ignored database errors in `database/db.go` `runSeeders()` function - The password migration seeder (which migrates user passwords to bcrypt) had three GORM operations whose errors were not checked ## Issues Fixed 1. **`Pluck("seeder_name", &seedersHistory)`** — If this fails, `seedersHistory` is empty, causing the seeder to re-run and potentially **double-hash already bcrypt'd passwords**, corrupting them and locking users out. 2. **`Find(&users)`** — If this fails, the `users` slice is empty, so no passwords get migrated, but the seeder still marks itself as complete. Users remain with old-format passwords indefinitely. 3. **`Update("password", hashedPassword)`** — If this fails for any user, their password silently remains in the old format while other users are migrated, creating an inconsistent state. All three now properly check errors and return early with descriptive log messages. ## Test plan - [ ] Verify the application starts normally with an existing database - [ ] Verify fresh installation still creates default admin user - [ ] Verify password migration from old format to bcrypt works correctly - [ ] Verify that a database error during migration is properly logged and does not mark the seeder as complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:48:15 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5626
No description provided.