fix: Fix flow addition to session and handle IntegrityError for orphaned flows (#4799)
* Handle IntegrityError specifically when assigning orphaned flows to superuser * Add missing session.add(flow) to ensure flow is added to the session before commit
This commit is contained in:
parent
b3181ce68a
commit
4620669129
2 changed files with 3 additions and 4 deletions
|
|
@ -187,6 +187,7 @@ class DatabaseService(Service):
|
|||
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()
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue