Description
When create_user() or create_organization() fails during await self.db_session.commit() in backend/app/utils/jwt_auth.py, the exception is re-raised without calling await self.db_session.rollback().
This leaves the SQLAlchemy session in a failed transaction state, which can cause later DB operations to fail with PendingRollbackError.
Steps to Reproduce
- Trigger a DB commit failure during signup/org creation
- Attempt another DB operation using the same session
- Observe transaction/session errors
Expected Behavior
The DB session should be rolled back after a failed commit.
Actual Behavior
The session remains in an invalid transaction state.
Suggested Fix
Add rollback handling inside the exception blocks:
except Exception:
await self.db_session.rollback()
raise
Environment
- Backend
- FastAPI
- SQLAlchemy AsyncSession
Description
When
create_user()orcreate_organization()fails duringawait self.db_session.commit()inbackend/app/utils/jwt_auth.py, the exception is re-raised without callingawait self.db_session.rollback().This leaves the SQLAlchemy session in a failed transaction state, which can cause later DB operations to fail with
PendingRollbackError.Steps to Reproduce
Expected Behavior
The DB session should be rolled back after a failed commit.
Actual Behavior
The session remains in an invalid transaction state.
Suggested Fix
Add rollback handling inside the exception blocks:
Environment