diff --git a/docs/en_US/release_notes_9_16.rst b/docs/en_US/release_notes_9_16.rst index 7e0b032931a..295b19ad791 100644 --- a/docs/en_US/release_notes_9_16.rst +++ b/docs/en_US/release_notes_9_16.rst @@ -40,3 +40,4 @@ Bug fixes | `Issue #9939 `_ - Fix saving a newly-added row in the Query Tool failing when the result set includes expression or alias columns that are not real columns of the underlying table. | `Issue #9976 `_ - Fix a startup migration crash (NoSuchTableError) when an old configuration database contains a stale foreign-key reference. | `Issue #9984 `_ - Fix the Docker entrypoint mishandling a quoted PGADMIN_CONFIG_CONFIG_DATABASE_URI, which caused a SQLAlchemy parse error and silently skipped PGADMIN_DEFAULT_EMAIL/PASSWORD setup. + | `Issue #10052 `_ - Fix a crash when checking an unreachable external configuration database, so first-launch setup proceeds instead of erroring. diff --git a/web/pgadmin/utils/check_external_config_db.py b/web/pgadmin/utils/check_external_config_db.py index 7ac91aa6e08..6549e17039f 100644 --- a/web/pgadmin/utils/check_external_config_db.py +++ b/web/pgadmin/utils/check_external_config_db.py @@ -17,11 +17,13 @@ def check_external_config_db(database_uri): """ engine = create_engine(database_uri) try: - connection = engine.connect() - if inspect(engine).has_table("server"): - return True - return False + # The context manager closes the connection on every path. The + # previous "finally: connection.close()" raised NameError when + # engine.connect() itself failed (e.g. an unreachable database), + # masking the intended "return False". + with engine.connect(): + return inspect(engine).has_table("server") except Exception: return False finally: - connection.close() + engine.dispose()