Skip to content
Merged
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion src/backend/base/langflow/services/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from contextlib import asynccontextmanager
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 +180,20 @@
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 400 <= e.status_code < 500:

Check failure on line 187 in src/backend/base/langflow/services/deps.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (PLR2004)

src/backend/base/langflow/services/deps.py:187:43: PLR2004 Magic value used in comparison, consider replacing `500` with a constant variable

Check failure on line 187 in src/backend/base/langflow/services/deps.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (PLR2004)

src/backend/base/langflow/services/deps.py:187:20: PLR2004 Magic value used in comparison, consider replacing `400` with a constant variable
# 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