Skip to content

Backup fails with PostgreSQL service connection (pg_service.conf) – NoneType has no attribute 'startswith' #9553

@IncidGeo

Description

@IncidGeo

Hi everyone,
Here is what i think is a bug :

Summary

pgAdmin fails when performing Backup on a PostgreSQL connection defined exclusively via pg_service.conf.
The connection itself works correctly, but the Backup action crashes with the following error:

'NoneType' object has no attribute 'startswith'

This issue is reproducible on multiple operating systems and pgAdmin versions, which strongly suggests a pgAdmin-side bug in the Backup code path when using service-based connections.


Steps to reproduce

  1. Define a PostgreSQL service in pg_service.conf, for example:

    [Ubuntu]
    host=192.168.10.61
    port=5432
    dbname=db
    user=postgres
    
  2. Ensure authentication is handled via .pgpass.

  3. In pgAdmin:

    • Register a new server
    • Set Service = Ubuntu
    • Leave host, port, database name and user fields empty
    • Save the connection
  4. Verify that the connection works (schemas can be expanded, queries run successfully).

  5. Right-click the database → Backup…

  6. Use default backup options and start the backup.


Expected result

The backup should execute successfully using pg_dump with the service-based connection.


Actual result

The backup fails immediately with the following error:

'NoneType' object has no attribute 'startswith'

No backup file is generated.


Environments where the issue occurs

Environment 1

  • OS: macOS Tahoe 26.2
  • pgAdmin: 9.11
  • PostgreSQL client: Postgres.app 17.2
  • PostgreSQL server OS: Ubuntu 24.04.2

Environment 2

  • OS: Ubuntu 24.04.2
  • pgAdmin: 9.4
  • PostgreSQL server: 17.x

The same behavior is observed on both environments.


Additional information

  • The connection works correctly when defined via pg_service.conf.

  • The issue does not occur when the connection is defined using explicit host/user/password fields.

  • The configured paths to PostgreSQL binaries in pgAdmin are correct.

  • Running pg_dump directly from the command line with the same service works perfectly, for example:

    pg_dump "service=Ubuntu" -Fc -f backup.dump

This confirms that PostgreSQL, libpq, and pg_service.conf are functioning correctly and that the failure is specific to pgAdmin’s Backup/Restore implementation when using service-only connections.


Conclusion

pgAdmin appears to incorrectly handle service-based connections in the Backup/Restore code path, likely passing None values internally when constructing the pg_dump command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions