Skip to content

Fix admin login 500: eliminate double-commit in get_master_db dependency#21

Closed
vincentmakes wants to merge 1 commit intomainfrom
claude/fix-admin-login-500-HU1gH
Closed

Fix admin login 500: eliminate double-commit in get_master_db dependency#21
vincentmakes wants to merge 1 commit intomainfrom
claude/fix-admin-login-500-HU1gH

Conversation

@vincentmakes
Copy link
Owner

The get_master_db dependency wrapped master_db.session() which auto-commits after yield, but admin route handlers also commit explicitly — causing a double-commit. More critically, the except Exception block in the auto-commit context manager intercepted HTTPExceptions during FastAPI's dependency cleanup, converting expected 401 responses into 500 Internal Server Errors.

Changes:

  • get_master_db now uses session_factory() directly (no auto-commit)
  • Test conftest overrides get_master_db so admin routes are testable
  • Add 8 admin auth tests (login, logout, session check)

https://claude.ai/code/session_01MDSKNbWA93pkLGyr2xMRYX

The `get_master_db` dependency wrapped `master_db.session()` which
auto-commits after yield, but admin route handlers also commit
explicitly — causing a double-commit.  More critically, the
`except Exception` block in the auto-commit context manager
intercepted HTTPExceptions during FastAPI's dependency cleanup,
converting expected 401 responses into 500 Internal Server Errors.

Changes:
- get_master_db now uses session_factory() directly (no auto-commit)
- Test conftest overrides get_master_db so admin routes are testable
- Add 8 admin auth tests (login, logout, session check)

https://claude.ai/code/session_01MDSKNbWA93pkLGyr2xMRYX
@vincentmakes vincentmakes deleted the claude/fix-admin-login-500-HU1gH branch February 26, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants