Skip to content

Commit 8457a60

Browse files
committed
tear down error issue
1 parent b0c386c commit 8457a60

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/backend/base/langflow/services/database/service.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ async def _with_session(self):
222222
async with self.async_session_maker() as session:
223223
yield session
224224

225+
def with_session(self):
226+
"""Return a database session context manager.
227+
228+
This public method preserves compatibility with existing call sites that
229+
still depend on ``with_session()`` while internal code migrates to
230+
``session_scope()`` helpers.
231+
"""
232+
return self._with_session()
233+
225234
async def assign_orphaned_flows_to_superuser(self) -> None:
226235
"""Assign orphaned flows to the default superuser when auto login is enabled."""
227236
settings_service = get_settings_service()

src/backend/base/langflow/services/deps.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,14 @@ def get_db_service(*, use_organisation: bool = True) -> DatabaseService:
152152
from langflow.services.database.organisation import OrganizationService
153153

154154
if use_organisation and get_settings_service().auth_settings.CLERK_AUTH_ENABLED:
155-
return OrganizationService.get_db_service_for_request()
155+
try:
156+
return OrganizationService.get_db_service_for_request()
157+
except RuntimeError as exc:
158+
# Anonymous/public requests can hit dependencies before an org-scoped
159+
# auth context exists. Fall back to the shared DB service instead of
160+
# emitting noisy errors on landing-page loads.
161+
if str(exc) != "Missing organisation id":
162+
raise
156163

157164
from langflow.services.database.factory import DatabaseServiceFactory
158165

0 commit comments

Comments
 (0)