Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/backend/base/langflow/services/deps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import annotations

from contextlib import asynccontextmanager
from http import HTTPStatus
from typing import TYPE_CHECKING

from fastapi import HTTPException
from lfx.log.logger import logger

from langflow.services.schema import ServiceType
Expand Down Expand Up @@ -179,8 +181,20 @@ async def session_scope() -> AsyncGenerator[AsyncSession, None]:
yield session
await session.commit()
except Exception as e:
await logger.aexception("An error occurred during the session scope.", exception=e)
await session.rollback()

Comment thread
jordanrfrazier marked this conversation as resolved.
# Log at appropriate level based on error type
if isinstance(e, HTTPException):
if HTTPStatus.BAD_REQUEST.value <= e.status_code < HTTPStatus.INTERNAL_SERVER_ERROR.value:
# Client errors (4xx) - log at info level
await logger.ainfo(f"Client error during session scope: {e.status_code}: {e.detail}")
else:
# Server errors (5xx) or other - log at error level
await logger.aexception("An error occurred during the session scope.", exception=e)
else:
# Non-HTTP exceptions - log at error level
await logger.aexception("An error occurred during the session scope.", exception=e)

Comment thread
jordanrfrazier marked this conversation as resolved.
raise


Expand Down
Loading