langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
34.22k stars 4.13k forks source link

Langflow not starting with postgres - giving Sqlite error #4572

Closed devinbost closed 1 day ago

devinbost commented 2 days ago

Bug Description

When I try starting Langflow on my Mac (latest version) when Langflow is configured to use Postgres, I get the following exception:

[11/13/24 12:40:49] ERROR    2024-11-13 12:40:49 - ERROR    - main - Error creating DB and tablesTraceback (most recent call last):                                                          main.py:114

                               File "/app/.venv/lib/python3.12/site-packages/langflow/services/database/utils.py", line 21, in initialize_database
                                 database_service.create_db_and_tables()
                                 |                -> <function DatabaseService.create_db_and_tables at 0xffff6a3ad3a0>
                                 -> <langflow.services.database.service.DatabaseService object at 0xffff571b3ec0>
                               File "/app/.venv/lib/python3.12/site-packages/langflow/services/database/service.py", line 318, in create_db_and_tables
                                 inspector = inspect(self.engine)
                                             |       |    -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                                             |       -> <langflow.services.database.service.DatabaseService object at 0xffff571b3ec0>
                                             -> <function inspect at 0xffff88b449a0>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/inspection.py", line 140, in inspect
                                 ret = reg(subject)
                                       |   -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                                       -> <function Inspector._engine_insp at 0xffff887aa840>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/reflection.py", line 312, in _engine_insp
                                 return Inspector._construct(Inspector._init_engine, bind)
                                        |         |          |         |             -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                                        |         |          |         -> <function Inspector._init_engine at 0xffff887aa480>
                                        |         |          -> <class 'sqlalchemy.engine.reflection.Inspector'>
                                        |         -> <classmethod(<function Inspector._construct at 0xffff887aa0c0>)>
                                        -> <class 'sqlalchemy.engine.reflection.Inspector'>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/reflection.py", line 245, in _construct
                                 init(self, bind)
                                 |    |     -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                                 |    -> <sqlalchemy.dialects.postgresql.base.PGInspector object at 0xffff571976b0>
                                 -> <function Inspector._init_engine at 0xffff887aa480>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/reflection.py", line 256, in _init_engine
                                 engine.connect().close()
                                 |      -> <function Engine.connect at 0xffff8871bb00>
                                 -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3278, in connect
                                 return self._connection_cls(self)
                                        |    |               -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                                        |    -> <class 'sqlalchemy.engine.base.Connection'>
                                        -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
                                 self._dbapi_connection = engine.raw_connection()
                                 |                        |      -> <function Engine.raw_connection at 0xffff8871bba0>
                                 |                        -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                                 -> <sqlalchemy.engine.base.Connection object at 0xffff571c6300>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3302, in raw_connection
                                 return self.pool.connect()
                                        |    |    -> <function Pool.connect at 0xffff88b1c900>
                                        |    -> <sqlalchemy.pool.impl.QueuePool object at 0xffff82c17a40>
                                        -> Engine(postgresql://langflow:***@postgres:5432/langflow)
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect
                                 return _ConnectionFairy._checkout(self)
                                        |                |         -> <sqlalchemy.pool.impl.QueuePool object at 0xffff82c17a40>
                                        |                -> <classmethod(<function _ConnectionFairy._checkout at 0xffff88b1ea20>)>
                                        -> <class 'sqlalchemy.pool.base._ConnectionFairy'>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout
                                 fairy = _ConnectionRecord.checkout(pool)
                                         |                 |        -> <sqlalchemy.pool.impl.QueuePool object at 0xffff82c17a40>
                                         |                 -> <classmethod(<function _ConnectionRecord.checkout at 0xffff88b1d580>)>
                                         -> <class 'sqlalchemy.pool.base._ConnectionRecord'>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
                                 rec = pool._do_get()
                                       |    -> <function QueuePool._do_get at 0xffff88b24860>
                                       -> <sqlalchemy.pool.impl.QueuePool object at 0xffff82c17a40>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
                                 with util.safe_reraise():
                                      |    -> <class 'sqlalchemy.util.langhelpers.safe_reraise'>
                                      -> <module 'sqlalchemy.util' from '/app/.venv/lib/python3.12/site-packages/sqlalchemy/util/__init__.py'>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
                                 raise exc_value.with_traceback(exc_tb)
                                       |         |              -> <traceback object at 0xffff81479580>
                                       |         -> <method 'with_traceback' of 'BaseException' objects>
                                       -> AttributeError("module 'sqlalchemy.dialects' has no attribute 'sqlite'")
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
                                 return self._create_connection()
                                        |    -> <function Pool._create_connection at 0xffff88b1c680>
                                        -> <sqlalchemy.pool.impl.QueuePool object at 0xffff82c17a40>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
                                 return _ConnectionRecord(self)
                                        |                 -> <sqlalchemy.pool.impl.QueuePool object at 0xffff82c17a40>
                                        -> <class 'sqlalchemy.pool.base._ConnectionRecord'>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
                                 self.__connect()
                                 -> <sqlalchemy.pool.base._ConnectionRecord object at 0xffff81c29730>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 914, in __connect
                                 )._exec_w_sync_on_first_run(self.dbapi_connection, self)
                                                             |    |                 -> <sqlalchemy.pool.base._ConnectionRecord object at 0xffff81c29730>
                                                             |    -> <member 'dbapi_connection' of '_ConnectionRecord' objects>
                                                             -> <sqlalchemy.pool.base._ConnectionRecord object at 0xffff81c29730>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/event/attr.py", line 483, in _exec_w_sync_on_first_run
                                 self(*args, **kw)
                                 |     |       -> {}
                                 |     -> (<connection object at 0xffff81549e40; dsn: 'user=langflow password=xxx dbname=langflow host=postgres port=5432', closed: 0>,...
                                 -> <sqlalchemy.event.attr._ListenerCollection object at 0xffff82c1e7d0>
                               File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/event/attr.py", line 495, in __call__
                                 fn(*args, **kw)
                                 |   |       -> {}
                                 |   -> (<connection object at 0xffff81549e40; dsn: 'user=langflow password=xxx dbname=langflow host=postgres port=5432', closed: 0>,...
                                 -> <bound method DatabaseService.on_connection of <langflow.services.database.service.DatabaseService object at 0xffff571b3ec0>>
                               File "/app/.venv/lib/python3.12/site-packages/langflow/services/database/service.py", line 121, in on_connection
                                 dbapi_connection, sqlite3.Connection | sa.dialects.sqlite.aiosqlite.AsyncAdapt_aiosqlite_connection
                                 |                 |       |            |  -> <module 'sqlalchemy.dialects' from '/app/.venv/lib/python3.12/site-packages/sqlalchemy/dialects/__init__.py'>
                                 |                 |       |            -> <module 'sqlalchemy' from '/app/.venv/lib/python3.12/site-packages/sqlalchemy/__init__.py'>
                                 |                 |       -> <class 'sqlite3.Connection'>
                                 |                 -> <module 'sqlite3' from '/usr/local/lib/python3.12/sqlite3/__init__.py'>
                                 -> <connection object at 0xffff81549e40; dsn: 'user=langflow password=xxx dbname=langflow host=postgres port=5432', closed: 0>

                             AttributeError: module 'sqlalchemy.dialects' has no attribute 'sqlite'

                             The above exception was the direct cause of the following exception:

                             Traceback (most recent call last):

                               File "/app/.venv/bin/langflow", line 8, in <module>
. . . 
                               File "/app/.venv/lib/python3.12/site-packages/langflow/main.py", line 93, in _initialize
                                 initialize_services(fix_migration=fix_migration)
                                 |                                 -> False
                                 -> <function initialize_services at 0xffff6a3ac900>
                               File "/app/.venv/lib/python3.12/site-packages/langflow/services/utils.py", line 164, in initialize_services
                                 initialize_database(fix_migration=fix_migration)
                                 |                                 -> False
                                 -> <function initialize_database at 0xffff6b0d59e0>
                               File "/app/.venv/lib/python3.12/site-packages/langflow/services/database/utils.py", line 28, in initialize_database
                                 raise RuntimeError(msg) from exc
                                                    -> 'Error creating DB and tables'

                             RuntimeError: Error creating DB and tables

                             ╭───────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────╮
                             │ /app/.venv/lib/python3.12/site-packages/langflow/services/database/utils.py:21 in initialize_database                                                       │
                             │                                                                                                                                                             │
                             │   18 │                                                                                                                                                      │
                             │   19 │   database_service: DatabaseService = get_db_service()                                                                                               │
                             │   20 │   try:                                                                                                                                               │
                             │ ❱ 21 │   │   database_service.create_db_and_tables()                                                                                                        │
                             │   22 │   except Exception as exc:                                                                                                                           │
                             │   23 │   │   # if the exception involves tables already existing                                                                                            │
                             │   24 │   │   # we can ignore it                                                                                                                             │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/langflow/services/database/service.py:318 in create_db_and_tables                                                   │
                             │                                                                                                                                                             │
                             │   315 │   def create_db_and_tables(self) -> None:                                                                                                           │
                             │   316 │   │   from sqlalchemy import inspect                                                                                                                │
                             │   317 │   │                                                                                                                                                 │
                             │ ❱ 318 │   │   inspector = inspect(self.engine)                                                                                                              │
                             │   319 │   │   table_names = inspector.get_table_names()                                                                                                     │
                             │   320 │   │   current_tables = ["flow", "user", "apikey", "folder", "message", "variable",                                                                  │
                             │       "transaction", "vertex_build"]                                                                                                                        │
                             │   321                                                                                                                                                       │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/inspection.py:140 in inspect                                                                             │
                             │                                                                                                                                                             │
                             │   137 │   │   │   │   continue                                                                                                                              │
                             │   138 │   │   │   elif reg is True:                                                                                                                         │
                             │   139 │   │   │   │   return subject                                                                                                                        │
                             │ ❱ 140 │   │   │   ret = reg(subject)                                                                                                                        │
                             │   141 │   │   │   if ret is not None:                                                                                                                       │
                             │   142 │   │   │   │   return ret                                                                                                                            │
                             │   143 │   else:                                                                                                                                             │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/reflection.py:312 in _engine_insp                                                                 │
                             │                                                                                                                                                             │
                             │    309 │                                                                                                                                                    │
                             │    310 │   @inspection._inspects(Engine)                                                                                                                    │
                             │    311 │   def _engine_insp(bind: Engine) -> Inspector:  # type: ignore[misc]                                                                               │
                             │ ❱  312 │   │   return Inspector._construct(Inspector._init_engine, bind)                                                                                    │
                             │    313 │                                                                                                                                                    │
                             │    314 │   @inspection._inspects(Connection)                                                                                                                │
                             │    315 │   def _connection_insp(bind: Connection) -> Inspector:  # type: ignore[misc]                                                                       │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/reflection.py:245 in _construct                                                                   │
                             │                                                                                                                                                             │
                             │    242 │   │   │   cls = bind.dialect.inspector                                                                                                             │
                             │    243 │   │                                                                                                                                                │
                             │    244 │   │   self = cls.__new__(cls)                                                                                                                      │
                             │ ❱  245 │   │   init(self, bind)                                                                                                                             │
                             │    246 │   │   return self                                                                                                                                  │
                             │    247 │                                                                                                                                                    │
                             │    248 │   def _init_legacy(self, bind: Union[Engine, Connection]) -> None:                                                                                 │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/reflection.py:256 in _init_engine                                                                 │
                             │                                                                                                                                                             │
                             │    253 │                                                                                                                                                    │
                             │    254 │   def _init_engine(self, engine: Engine) -> None:                                                                                                  │
                             │    255 │   │   self.bind = self.engine = engine                                                                                                             │
                             │ ❱  256 │   │   engine.connect().close()                                                                                                                     │
                             │    257 │   │   self._op_context_requires_connect = True                                                                                                     │
                             │    258 │   │   self.dialect = self.engine.dialect                                                                                                           │
                             │    259 │   │   self.info_cache = {}                                                                                                                         │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py:3278 in connect                                                                           │
                             │                                                                                                                                                             │
                             │   3275 │   │                                                                                                                                                │
                             │   3276 │   │   """                                                                                                                                          │
                             │   3277 │   │                                                                                                                                                │
                             │ ❱ 3278 │   │   return self._connection_cls(self)                                                                                                            │
                             │   3279 │                                                                                                                                                    │
                             │   3280 │   def raw_connection(self) -> PoolProxiedConnection:                                                                                               │
                             │   3281 │   │   """Return a "raw" DBAPI connection from the connection pool.                                                                                 │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py:146 in __init__                                                                           │
                             │                                                                                                                                                             │
                             │    143 │   │                                                                                                                                                │
                             │    144 │   │   if connection is None:                                                                                                                       │
                             │    145 │   │   │   try:                                                                                                                                     │
                             │ ❱  146 │   │   │   │   self._dbapi_connection = engine.raw_connection()                                                                                     │
                             │    147 │   │   │   except dialect.loaded_dbapi.Error as err:                                                                                                │
                             │    148 │   │   │   │   Connection._handle_dbapi_exception_noconnection(                                                                                     │
                             │    149 │   │   │   │   │   err, dialect, engine                                                                                                             │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py:3302 in raw_connection                                                                    │
                             │                                                                                                                                                             │
                             │   3299 │   │   │   :ref:`dbapi_connections`                                                                                                                 │
                             │   3300 │   │                                                                                                                                                │
                             │   3301 │   │   """                                                                                                                                          │
                             │ ❱ 3302 │   │   return self.pool.connect()                                                                                                                   │
                             │   3303                                                                                                                                                      │
                             │   3304                                                                                                                                                      │
                             │   3305 class OptionEngineMixin(log.Identified):                                                                                                             │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py:449 in connect                                                                              │. . .                                                                                                    │
                             ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                             AttributeError: module 'sqlalchemy.dialects' has no attribute 'sqlite'

                             The above exception was the direct cause of the following exception:

                             ╭───────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────╮
                             │ /app/.venv/lib/python3.12/site-packages/langflow/main.py:106 in lifespan                                                                                    . . . 
                             │                                                                                                                                                             │
                             │   161 │   # Test cache connection                                                                                                                           │
                             │   162 │   get_service(ServiceType.CACHE_SERVICE, default=CacheServiceFactory())                                                                             │
                             │   163 │   # Setup the superuser                                                                                                                             │
                             │ ❱ 164 │   initialize_database(fix_migration=fix_migration)                                                                                                  │
                             │   165 │   setup_superuser(get_service(ServiceType.SETTINGS_SERVICE), next(get_session()))                                                                   │
                             │   166 │   try:                                                                                                                                              │
                             │   167 │   │   get_db_service().migrate_flows_if_auto_login()                                                                                                │
                             │                                                                                                                                                             │
                             │ /app/.venv/lib/python3.12/site-packages/langflow/services/database/utils.py:28 in initialize_database                                                       │
                             │                                                                                                                                                             │
                             │   25 │   │   if "already exists" not in str(exc):                                                                                                           │
                             │   26 │   │   │   msg = "Error creating DB and tables"                                                                                                       │
                             │   27 │   │   │   logger.exception(msg)                                                                                                                      │
                             │ ❱ 28 │   │   │   raise RuntimeError(msg) from exc                                                                                                           │
                             │   29 │   try:                                                                                                                                               │
                             │   30 │   │   database_service.check_schema_health()                                                                                                         │
                             │   31 │   except Exception as exc:                                                                                                                           │
                             ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                             RuntimeError: Error creating DB and tables
. . . 
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
  File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 914, in __connect
    )._exec_w_sync_on_first_run(self.dbapi_connection, self)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/event/attr.py", line 483, in _exec_w_sync_on_first_run
    self(*args, **kw)
  File "/app/.venv/lib/python3.12/site-packages/sqlalchemy/event/attr.py", line 495, in __call__
    fn(*args, **kw)
  File "/app/.venv/lib/python3.12/site-packages/langflow/services/database/service.py", line 121, in on_connection
    dbapi_connection, sqlite3.Connection | sa.dialects.sqlite.aiosqlite.AsyncAdapt_aiosqlite_connection
                                           ^^^^^^^^^^^^^^^^^^
AttributeError: module 'sqlalchemy.dialects' has no attribute 'sqlite'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/starlette/routing.py", line 693, in lifespan
    async with self.lifespan_context(app) as maybe_state:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 133, in merged_lifespan
    async with original_context(app) as maybe_original_state:
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 133, in merged_lifespan
    async with original_context(app) as maybe_original_state:
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 133, in merged_lifespan
    async with original_context(app) as maybe_original_state:
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/langflow/main.py", line 106, in lifespan
    await asyncio.to_thread(_initialize)
  File "/usr/local/lib/python3.12/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.12/site-packages/langflow/main.py", line 93, in _initialize
    initialize_services(fix_migration=fix_migration)
  File "/app/.venv/lib/python3.12/site-packages/langflow/services/utils.py", line 164, in initialize_services
    initialize_database(fix_migration=fix_migration)
  File "/app/.venv/lib/python3.12/site-packages/langflow/services/database/utils.py", line 28, in initialize_database
    raise RuntimeError(msg) from exc
RuntimeError: Error creating DB and tables

Application startup failed. Exiting.

Reproduction

Start langflow by starting the following docker compose file:

version: "0.4.12"
networks:
  langflow-network:
    driver: bridge
services:
  langflow:
    image: (arm 64 build of latest)
    ports:
      - "7860:7860"
    depends_on:
      - postgres
      - registry
    environment:
      - LANGFLOW_DATABASE_URL=postgresql://langflow:langflow@postgres:5432/langflow
      - LANGFLOW_LANGCHAIN_CACHE=InMemoryCache
      - LANGFLOW_WORKERS=1
      - LANGFLOW_BACKEND_ONLY=true
      - LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true
      - LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT=HUGGINGFACE_MODEL_PATH,CASSANDRA_CONTACT_POINTS,CASSANDRA_USERNAME,CASSANDRA_PASSWORD,CASSANDRA_DATA_ENDPOINT,CASSANDRA_COLLECTION,REST_API_KEY,REST_LSL_KEY,REST_ENDPOINT,ASTRA_DB_TOKEN,ASTRA_DB_DATABASE_ID,MYSQL_DB,MYSQL_USER,MYSQL_PASSWORD,MYSQL_HOST,OPENAI_KEY
      - COLUMNS=200
    volumes:
      - ./langflow-data:/app/langflow
      - ./huggingface:/app/huggingface
      - ./.env.development:/app/.env
      - ./flows:/app/flows
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    networks:
      - langflow-network

  postgres:
    image: postgres:16
    environment:
      POSTGRES_USER: langflow
      POSTGRES_PASSWORD: langflow
      POSTGRES_DB: langflow
    ports:
      - "5432:5432"
    volumes:
      - langflow-postgres:/var/lib/postgresql/data
    networks:
      - langflow-network

volumes:
  langflow-postgres:
  langflow-data:

Expected behavior

Langflow should start normally and use Postgres, not crash due to a missing sqlite dependency.

Who can help?

No response

Operating System

Mac M1 (Apple Silicon)

Langflow Version

bleeding edge (after 1.0.19.post2)

Python Version

None

Screenshot

No response

Flow File

No response

dosubot[bot] commented 2 days ago

The error you're encountering seems to be related to an incorrect handling of database connections, specifically with the on_connection method in the DatabaseService class. This method is trying to access sqlite attributes even though you're using PostgreSQL, which is causing the AttributeError.

Here's a potential solution to address this issue:

  1. Check the on_connection Method: Ensure that the on_connection method in your codebase is correctly handling the database connection type. It should only apply SQLite-specific settings when the connection is indeed an SQLite connection. The method should look something like this:

    @event.listens_for(Engine, "connect")
    def on_connection(dbapi_connection, connection_record):
       from sqlite3 import Connection as sqliteConnection
    
       if isinstance(dbapi_connection, sqliteConnection):
           logger.info("sqlite connect listener, setting pragmas")
           cursor = dbapi_connection.cursor()
           try:
               cursor.execute("PRAGMA synchronous = NORMAL")
               cursor.execute("PRAGMA journal_mode = WAL")
               cursor.close()
           except OperationalError as oe:
               logger.warning("Failed to set PRAGMA: ", {oe})

    Ensure that this method is not being called or attempting to set SQLite-specific settings when using PostgreSQL.

  2. Database URL Configuration: Double-check your LANGFLOW_DATABASE_URL environment variable to ensure it is correctly set to use PostgreSQL. It should be in the format postgresql://user:password@host:port/dbname.

  3. Dependencies: Make sure that your environment does not have any unnecessary SQLite dependencies that might be causing conflicts. Since you're using PostgreSQL, these should not be required.

By ensuring that the on_connection method is correctly implemented and that your environment is properly configured for PostgreSQL, you should be able to resolve this issue. If the problem persists, consider reviewing the initialization logic to ensure that it correctly distinguishes between different database backends [1].

To continue talking to Dosu, mention @dosu.

devinbost commented 2 days ago

I think this may be caused by a dependency conflict from adding packages after the image is built. I'm investigating further.

9n commented 2 days ago

same error

HHXiaoFu commented 2 days ago

same error

marfal commented 2 days ago

same

devinbost commented 1 day ago

I'm also getting this issue on v1.1.0

@italojohnny ?

devinbost commented 1 day ago

I verified that it's not caused by any dependency issues. Even a clean build is causing this.

mataide commented 1 day ago

The problem is with the new 1.1.0 version, rollback to: FROM langflowai/langflow:v1.0.19.post2 and it works.

devinbost commented 1 day ago

@zzzming FYI

joao-santillo commented 1 day ago

Same here, trying an older version

joao-santillo commented 1 day ago

The problem is with the new 1.1.0 version, rollback to: FROM langflowai/langflow:v1.0.19.post2 and it works.

Solved, thanks

Kraego commented 1 day ago

Will there be a patch version for 1.1.0 ? And when? Thanks

John0x commented 1 day ago

Please update the docker image as soon as possible :) This is currently breaking things