Skip to content

[Regression] ERD Tool crashes in pgAdmin 4 v9.19 on macOS — works in v9.18 #10728

Not planned

Description

@gersonndiaz

Description

While designing a database schema using the ERD Tool in pgAdmin 4 v9.19 on macOS, the tool unexpectedly crashed and started displaying the generic "Something went wrong" error.

Restarting pgAdmin and the PostgreSQL service did not resolve the issue.

The Query Tool and other database operations continued working correctly.

Steps to reproduce

Open pgAdmin 4 v9.19 on macOS.

Connect to a PostgreSQL database.

Open the ERD Tool and design a database schema.

The ERD Tool unexpectedly crashes.

Attempt to reopen the ERD Tool.

Actual behavior

The ERD Tool fails with "Something went wrong".

The pgAdmin log contains:

AttributeError: 'NoneType' object has no attribute 'close'

pgadmin/tools/erd/init.py
initialize_erd()
_get_connection()

pgadmin/utils/driver/psycopg3/connection.py
connect()
_initialize()
self.conn.close()

Expected behavior

The ERD Tool should open and allow database schema design without crashing.

Workaround

Downgrading from pgAdmin 4 v9.19 to v9.18 resolved the issue. The ERD Tool works correctly again with the previous version.

Environment

Operating system: macOS 27.2

pgAdmin affected version: 9.19

pgAdmin working version: 9.18

Deployment: Desktop application

PostgreSQL 18.6: Working correctly

Additional information

The issue appears to be a regression introduced in v9.19, potentially related to connection initialization in the ERD module.

The underlying cause has not yet been identified.

Activity

  1. dpage commented on Nov 5, 2026

    @dpage
    Contributor

    Thanks for the report. The AttributeError is a secondary failure: a query that pgAdmin runs while setting up the connection failed first, and the error handler then tripped over the already-closed connection, which hid the original error. I'll fix the handler so the real error is shown, but I can't reproduce the underlying failure here, so could you help with a few details?

    • The full traceback from pgadmin4.log, in particular any error logged just before the AttributeError.
    • Whether the server's connection is configured with a role, post-connection SQL or an SSH tunnel.
    • The PostgreSQL version and the encoding of the database you open the ERD tool on.
  2. gersonndiaz commented on Nov 5, 2026

    @gersonndiaz
    Author

    Hi! Thank you for your response and for investigating this issue.

    I appreciate your explanation regarding the secondary AttributeError and your willingness to fix the error handling.

    I'm happy to provide the additional information I was able to collect.

    1. Original traceback and log files

    Unfortunately, after downgrading from pgAdmin 4 v9.19 to v9.18, I performed a complete cleanup of the previous installation using PureMac, including removing the ~/.pgadmin directory and its log files.

    I needed to continue working on my development projects, so I performed a completely fresh installation of v9.18, which has been working correctly since then.

    However, before removing the previous installation, I captured the following error from pgadmin4.log:

    2026-11-03 22:44:31,321: ERROR pgadmin:
    'NoneType' object has no attribute 'close'
    

    Traceback (most recent call last):

    File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/utils/driver/psycopg3/connection.py", line 641, in connect
    status, msg = self._initialize(conn_id, **kwargs)

    File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/utils/driver/psycopg3/connection.py", line 775, in _initialize
    self.conn.close()

    AttributeError: 'NoneType' object has no attribute 'close'

    The same error also appeared in the full traceback originating from the ERD Tool:

    File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/tools/erd/init.py", line 608, in initialize_erd
    conn = _get_connection(sid, did, trans_id, data.get('db_name', None))

    File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/tools/erd/init.py", line 649, in _get_connection
    status, msg = conn.connect()

    File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/utils/driver/psycopg3/connection.py", line 641, in connect
    status, msg = self._initialize(conn_id, **kwargs)

    File "/Applications/pgAdmin 4.app/Contents/Resources/web/pgadmin/utils/driver/psycopg3/connection.py", line 775, in _initialize
    self.conn.close()

    AttributeError: 'NoneType' object has no attribute 'close'

    Additional log observation:

    The only preceding SQL error I captured was approximately 14 minutes earlier, at 2026-11-03 22:30:53.

    It was caused by an invalid primary key definition in a SQL script generated while working on the database schema:

    PRIMARY KEY (id, id)

    PostgreSQL returned:

    ERROR: column "id" appears twice in primary key constraint
    SQL state: 42701

    I corrected this SQL definition before the ERD connection error occurred.

    I don't believe these two errors are necessarily related, but I'm mentioning it for completeness.

    Unfortunately, I did not capture any other error immediately preceding the AttributeError, and the original log file is no longer available.

    2. PostgreSQL connection configuration

    I checked the server connection properties in my current pgAdmin 4 v9.18 installation.

    The configuration is:

    Setting Value
    Host localhost
    Port 5432
    Maintenance database postgres
    Username / Login role gersondiaz
    Login role privileges Superuser
    Connection role None (empty field)
    SSH tunnel Not used
    Kerberos authentication Disabled
    Service None (empty field)

    The PostgreSQL server runs locally on the same macOS machine as pgAdmin.

    Regarding Post-connection SQL, I have not intentionally configured any initialization statements. I still need to verify whether that field is empty.

    Please note that these settings were checked after the clean installation of v9.18, so I cannot independently verify that every setting was identical in the previous v9.19 installation.

    3. PostgreSQL version and database encoding

    The PostgreSQL environment is:

    • PostgreSQL version: 18.6

    • Database encoding: UTF8

    • Operating system: macOS

    • pgAdmin affected version: 9.19

    • pgAdmin working version: 9.18

    • Deployment: Desktop application

    4. Additional observations

    The issue appeared unexpectedly while I was actively designing a database schema using the ERD Tool.

    Before the failure, I was able to:

    • Work with the ERD designer.

    • Generate SQL scripts from the diagram.

    • Execute SQL queries successfully.

    • Create database objects in PostgreSQL.

    After the ERD Tool failed, PostgreSQL itself continued working normally, and I could still execute queries using the Query Tool.

    I also tried restarting both pgAdmin and the PostgreSQL service, but the problem persisted.

    The issue appeared to be isolated to the ERD Tool.

    5. Downgrade results

    After experiencing the issue with pgAdmin 4 v9.19, I downgraded to v9.18 and performed a completely clean installation.

    Since then, the ERD Tool has been working correctly with the same PostgreSQL 18.6 server.

    This suggests a possible regression introduced in v9.19, although I understand that the underlying connection initialization failure has not yet been identified.

    Unfortunately, I cannot reproduce the original issue at the moment without reinstalling v9.19, which would interrupt my current development environment.

    If a future version includes improved error handling or additional diagnostics, I would be happy to help test it and provide more information.

    Thank you again for your time and for maintaining pgAdmin. I hope these details help narrow down the issue!

  3. dpage commented on Nov 27, 2026

    @dpage
    Contributor

    Thanks for all the detail. The handler fix from #10741 will be in the next release, 9.20, so pgAdmin will log the real error instead of the AttributeError. As we can't reproduce the underlying failure here and the 9.19 logs are gone, I'm closing this for now. Please re-test with 9.20 when it's out; if the ERD Tool still fails, re-open this issue and attach the error that pgadmin4.log records just before it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions