Skip to content
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

pg:copy doesn't use the real affected app on the confirmation prompt #1545

Open
iriberri opened this issue Jun 12, 2020 · 0 comments
Open

pg:copy doesn't use the real affected app on the confirmation prompt #1545

iriberri opened this issue Jun 12, 2020 · 0 comments

Comments

@iriberri
Copy link
Contributor

Description

The heroku pg:copy command expects the source and target arguments, as well as the --app flag. Although the --app flag is required, it's only used to resolve attachment names within the command, if needed, and such app doesn't need to be related to the source and target databases.

When the command confirmation is prompted, it uses target.confirm, which is earlier set to the value from the --app flag in the command (except in the case where a URL is used).

However, the app name specified in --app isn't necessarily the app related to the target database. This confirmation prompt can cause confusion and lead to data loss, given that one would think that the database that's going to be overwritten is the one mentioned (and typed) in the --confirm prompt, but that might not be the case.

Current behavior

Running:

heroku pg:copy DATABASE bar::DATABASE --app foo

implies that, internally:

source: foo::DATABASE
target: bar::DATABASE
target.confirm: foo <-

which will cause the confirmApp prompt to ask the user to confirm this operation by typing foo, whereas the affected app is really bar:

image

In the command above, foo is used to resolve the source DATABASE attachment, but the --app argument shouldn't be understood as the target app by default, which seems to be the current behavior.

Expected behavior

Running:

heroku pg:copy DATABASE bar::DATABASE --app foo

should ask to type bar in the confirmation prompt, given that bar::DATABASE is the database that's going to be overwritten.

This is, target.confirm should be set to the app related to the target attachment, and not directly assigned to the value of the --app flag in the command.

CLI version

$ heroku version
heroku/7.42.1 darwin-x64 node-v12.16.2

In the current revision for pg-v5/commands/copy.js:

.


Looking for previously reported issues, this is slightly related to #687. However, that issue focuses on the confirmApp prompt not being specific and not showing "fully-qualified" attachment names in the confirmation message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant