{"record":{"id":"dbc0ab7c6119c632","repo":"zylon-ai/private-gpt","slug":"one-or-more-database-connections-failed-n-errors","errorCode":null,"errorMessage":"One or more database connections failed: \\n{errors}","messagePattern":"One or more database connections failed: \\\\n(.+?)","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/tools/builders/database_query_builder.py","lineNumber":240,"sourceCode":"                    enable_functions=sql_artifact.enable_functions,\n                    enable_procedures=sql_artifact.enable_procedures,\n                    description=sql_artifact.description,\n                    batch_size=self.settings.database_query.batch_size,\n                    timeout_seconds=self.settings.database_query.timeout_seconds,\n                    max_mb_result=self.settings.database_query.max_mb_result,\n                    cache=self.cache,\n                )\n                for sql_artifact in sql_artifacts\n            ]\n            validations = [gen.check_connection() for gen in query_gen]\n            results = list(await asyncio.gather(*validations, return_exceptions=True))\n            errors = [\n                f\"- DB {i} connection error: {result!s}\\n\"\n                for i, result in enumerate(results)\n                if isinstance(result, str | Exception)\n            ]\n            if errors:\n                raise ConnectionError(\n                    \"One or more database connections failed: \\n\" + \"; \".join(errors),\n                )\n\n        @auto_resolve_media_blocks(blob_visibility=blob_visibility)\n        async def execute_sql(query: str) -> list[ResultContentBlockType]:\n            additional_context: str | None = await asyncio.to_thread(\n                self._get_additional_context,\n                chat_history,\n            )\n            query_gen = []\n            try:\n                query_gen = [\n                    database_query_generator_cls(\n                        connection_string=sql_artifact.connection_string,\n                        ssl=sql_artifact.ssl,\n                        schemas=sql_artifact.schemas,\n                        enable_tables=sql_artifact.enable_tables,\n                        enable_views=sql_artifact.enable_views,","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/tools/builders/database_query_builder.py#L222-L258","documentation":"ConnectionError raised by the validate_sql closure after running check_connection() on every DatabaseQueryGenerator concurrently with asyncio.gather(return_exceptions=True). Any connection that returned an error string or raised is collected as '- DB {i} connection error: ...' lines and joined into the message.","triggerScenarios":"One or more sql_artifacts have unreachable or misconfigured connection strings: wrong host/port, bad credentials, missing SSL config, or an engine whose driver was not installed; check_connection either raises or returns an error string.","commonSituations":"Database behind a firewall/VPC not reachable from the app; expired or wrong password; ssl=True against a server with no TLS; using a postgres connection string in an environment where only database-mysql extra was installed.","solutions":["Read the per-DB lines in the message to identify which index failed and why (index order matches sql_artifacts order).","Test connectivity with the same connection string using a plain client (psql/sqlcmd) or a small asyncpg/sqlalchemy script from the same host.","Verify credentials, host, port, and ssl flag in each artifact's connection_string; install the driver extra for every engine used (e.g. uv sync --inexact --extra database-postgres).","If failures are transient (network blip), retry after fixing network/DNS."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import asyncio\n\nasync def probe_connections(sql_artifacts):\n    results = await asyncio.gather(*(gen.check_connection() for gen in gens), return_exceptions=True)\n    return [r for r in results if isinstance(r, (str, Exception)) and r not in (None, True)]","typeGuard":null,"tryCatchPattern":"try:\n    await validate_sql()\nexcept ConnectionError as e:\n    errors = str(e).splitlines()\n    # map '- DB {i} connection error' lines back to sql_artifacts[i] and report which DB failed\n    raise","preventionTips":["Pre-check each connection_string with a lightweight client before enabling the tool.","Keep credentials/DNS/SSL config for every artifact in sync with the database side.","Treat transient network failures as retryable, but fix auth/config errors before retrying."],"tags":["database","connection","network","credentials"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}