diff --git a/backend/app/database.py b/backend/app/database.py index 095cf72..9d917b2 100644 --- a/backend/app/database.py +++ b/backend/app/database.py @@ -28,11 +28,15 @@ class Base(DeclarativeBase): async def get_db() -> AsyncSession: - """Dependency that yields an async database session.""" + """Dependency that yields an async database session. + + Handlers are responsible for committing or rolling back their own + transactions. This avoids the double-commit problem where the + session is committed both here and in the handler. + """ async with async_session_factory() as session: try: yield session - await session.commit() except Exception: await session.rollback() raise