Skip to content

fix: pg:copy confirmation prompt shows addon name not app name - #3834

Merged
heroku-johnny merged 4 commits into
mainfrom
W-23597886
Jul 28, 2026
Merged

fix: pg:copy confirmation prompt shows addon name not app name#3834
heroku-johnny merged 4 commits into
mainfrom
W-23597886

Conversation

@heroku-johnny

Copy link
Copy Markdown
Contributor

Summary

  • Bug: pg:copy destructive-action confirmation prompt asked users to type the app name to confirm, even when the target was a named Heroku PostgreSQL attachment. A user copying to the wrong database on the same app would see an identical prompt for both, providing no safety signal.
  • Data-loss risk: Because the confirm value was always the app name, not the specific database, a mistaken heroku pg:copy SOURCE TARGET against the wrong database on the same app would clear and overwrite data with no distinguishing warning. This is a real data-safety gap.
  • Fix: Extract the human-readable addon name (e.g. JADE, CRIMSON) from the config-var attachment name and use it for both name and confirm, mirroring the existing behavior of the postgres:// URL branch which already correctly uses conn.database || conn.host.

Fixes: W-23597886
Related: #1545

Before / After

Before — both prompts for two databases on the same app look identical:

WARNING: Destructive action
This command will remove all data from JADE
Type my-app to confirm: _

After — each prompt names the specific database:

WARNING: Destructive action
This command will remove all data from JADE
Type JADE to confirm: _

Test plan

  • heroku pg:copy SOURCE TARGET --app my-app where target is a named attachment: prompt asks you to type the addon name (e.g. JADE), not the app name.
  • heroku pg:copy postgres://... TARGET --app my-app: existing behavior unchanged — prompt still uses conn.database || conn.host.
  • Providing the wrong confirmation string still aborts without copying.
  • --confirm JADE flag bypasses the prompt correctly.

🤖 Generated with Claude Code

The destructive-action confirmation prompt in `pg:copy` was asking the
user to type the app name to confirm, even when the target was a Heroku
PostgreSQL attachment. This meant that copying to the wrong database on
the same app would show an identical prompt with no way to distinguish
targets — a silent data-loss risk.

The `postgres://` URL branch already used the database name as the
`confirm` value. This commit aligns the attachment branch to do the
same: extract the human-readable addon name (e.g. `JADE`) from the
attachment's config-var name and use it for both `name` and `confirm`.

Fixes: W-23597886
Related: #1545

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@heroku-johnny
heroku-johnny requested a review from a team as a code owner July 27, 2026 19:15
The fix to `getAttachmentInfo` changed `confirm` from the app name to
the attachment addon name. Update all existing test cases that passed
`--confirm <app>` to pass `--confirm <addon>` instead, and add a
regression test that explicitly verifies the app name is rejected when
a specific addon name is required.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

@tlowrimore-heroku tlowrimore-heroku left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlowrimore-heroku tlowrimore-heroku left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it looks like something has broken the integration tests.

@tlowrimore-heroku tlowrimore-heroku left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@heroku-johnny
heroku-johnny merged commit 44c5786 into main Jul 28, 2026
19 checks passed
@heroku-johnny
heroku-johnny deleted the W-23597886 branch July 28, 2026 18:49
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

Successfully merging this pull request may close these issues.

2 participants