Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix flow addition to session and handle IntegrityError for orphaned flows #4799

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/backend/base/langflow/services/database/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ async def assign_orphaned_flows_to_superuser(self) -> None:
flow.user_id = superuser.id
flow.name = self._generate_unique_flow_name(flow.name, existing_names)
existing_names.add(flow.name)
session.add(flow)

# Commit changes
await session.commit()
Expand Down
6 changes: 2 additions & 4 deletions src/backend/base/langflow/services/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ async def initialize_services(*, fix_migration: bool = False) -> None:
await setup_superuser(settings_service, session)
try:
await get_db_service().assign_orphaned_flows_to_superuser()
except Exception as exc:
msg = "Error assigning orphaned flows to the superuser"
logger.exception(msg)
raise RuntimeError(msg) from exc
except sqlalchemy_exc.IntegrityError as exc:
logger.warning(f"Error assigning orphaned flows to the superuser: {exc!s}")
await clean_transactions(settings_service, session)
await clean_vertex_builds(settings_service, session)
Loading