-
Notifications
You must be signed in to change notification settings - Fork 817
Fix pgAdmin fails when performing Backup/Restore on a PostgreSQL connection defined exclusively via pg_service.conf. #9553 #9571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds an Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Message as Backup/RestoreMessage
participant SSH as SSHTunnelManager
participant Server
participant Util as pg_dump/pg_restore
Client->>Message: details(cmd, args)
Message->>Message: store arg_list = args
Message->>Message: get_server_name() checks arg_list
alt host/port in arg_list
Message->>Message: use host/port from arg_list
else
Message->>SSH: query binding for server_id
alt SSH has binding
SSH->>Message: bound_host/bound_port
else
Message->>Server: fetch host/port
Server->>Message: host/port
end
end
Message->>Message: build args list incrementally (--file, optional --host/--port/--username, --no-password)
Message->>Util: execute with constructed args
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@web/pgadmin/tools/restore/__init__.py`:
- Around line 368-384: The args list built in get_sql_util_args must include the
'--no-password' flag to mirror get_restore_util_args and prevent psql from
hanging waiting for interactive password input; update the args construction in
get_sql_util_args (the list containing '--dbname', '-c', '--file' etc.) to
append '--no-password' (unconditionally or under the same conditions used for
get_restore_util_args) so psql runs non-interactively in batch processes.
🧹 Nitpick comments (1)
web/pgadmin/tools/backup/__init__.py (1)
210-211: Consider documenting the'None'string check.The check
port != 'None'guards against the case wherestr(server.port)yields the literal string'None'when the port isNone. While this works, it's a subtle edge case that may confuse future maintainers.💡 Optional: Add a brief comment or refactor for clarity
- if port and port != 'None': + # port may be string 'None' when server.port is None + if port and port != 'None': args.extend(['--port', port])Alternatively, handle the conversion earlier:
port = str(manager.local_bind_port) if manager.use_ssh_tunnel else ( str(server.port) if server.port is not None else None ) # ... if port: args.extend(['--port', port])
22b5d83 to
29624d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@web/pgadmin/tools/backup/__init__.py`:
- Around line 138-142: The f-string is broken by nested single quotes around
gettext('Service') inside the returned f-string; fix by avoiding nested
quoting—either change the inner f-string to use double quotes (e.g.,
f"{gettext('Service')}: {s.service}") or precompute the label (label =
gettext('Service')) and use that in the return expression that references
s.name, s.service, host, port so the f-string becomes well-formed.
In `@web/pgadmin/tools/restore/__init__.py`:
- Around line 114-118: The f-string in the return expression that builds the
server name (the expression starting with return f"{s.name} (...") contains
nested single quotes around 'Service' which breaks parsing; change how the
Service label is composed—either use double quotes inside the inner f-string
(e.g., f"Service") or build the label outside the f-string and include that
variable in the join—so that the fragment f'{_('Service')}: {s.service}' is
replaced by a valid string construction (for example using _("Service") with
double quotes or precomputing service_label) and then return the final formatted
string; update the expression that references s.name, _('Service'), s.service,
host, and port accordingly.
29624d4 to
a9789b6
Compare
…ection defined exclusively via pg_service.conf. pgadmin-org#9553
a9789b6 to
eda91aa
Compare
Detail Info: #9553
Summary by CodeRabbit
New Features
Bug Fixes / Improvements
✏️ Tip: You can customize this high-level summary in your review settings.