From 61a5c9dcdb59f8f404454a1a6cd10c995b8b27c7 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 7 Oct 2023 12:03:51 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20improve=20error?= =?UTF-8?q?=20handling=20in=20initialize=5Fdatabase()=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `initialize_database()` function now handles two specific exceptions: "overlaps with other requested revisions" and "Can't locate revision identified by". If either of these exceptions occur, they will not be raised and instead the `alembic_version` table will be deleted. This change improves the error handling and ensures that the database is properly initialized. --- src/backend/langflow/services/database/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/services/database/utils.py b/src/backend/langflow/services/database/utils.py index 968cfef59..b457b70e2 100644 --- a/src/backend/langflow/services/database/utils.py +++ b/src/backend/langflow/services/database/utils.py @@ -32,7 +32,11 @@ def initialize_database(): try: database_service.run_migrations() except CommandError as exc: - if "Can't locate revision identified by" not in str(exc): + # if "overlaps with other requested revisions" or "Can't locate revision identified by" + # are not in the exception, we can't handle it + if "overlaps with other requested revisions" not in str( + exc + ) and "Can't locate revision identified by" not in str(exc): raise exc # This means there's wrong revision in the DB # We need to delete the alembic_version table