Skip to content

fix(cli): Move DELETE confirmation prompt to vercel api command only#14784

Closed
developerjhp wants to merge 1 commit intovercel:mainfrom
developerjhp:fix/env-rm-non-tty-mode
Closed

fix(cli): Move DELETE confirmation prompt to vercel api command only#14784
developerjhp wants to merge 1 commit intovercel:mainfrom
developerjhp:fix/env-rm-non-tty-mode

Conversation

@developerjhp
Copy link
Copy Markdown
Contributor

Problem

PR #14769 introduced a DELETE confirmation prompt for AI agent safety, but incorrectly placed the confirmMutatingOperation() call inside client.fetch(). This caused ALL commands using DELETE API calls (e.g., vercel env rm, vercel remove) to fail in non-TTY environments (CI/CD pipelines).

Error Message

Error: DELETE operations require confirmation. Use --dangerously-skip-permissions to skip confirmation in non-interactive mode.

Root Cause

  1. confirmMutatingOperation() was called on every client.fetch() with DELETE method
  2. In non-TTY mode, it requires --dangerously-skip-permissions flag to proceed
  3. But this flag was only added to the vercel api command
  4. Other commands like env rm have their own --yes flag for confirmation, which became ineffective

Solution

Move the DELETE confirmation logic to only apply to vercel api command:

  1. Remove confirmMutatingOperation() call from client.fetch()
  2. Change confirmMutatingOperation() from private to public method
  3. Call confirmMutatingOperation() directly in vercel api's executeSingleRequest()
  4. Update tests to call confirmMutatingOperation() directly instead of through fetch()

Changes

packages/cli/src/util/client.ts

  • Remove confirmation call from fetch() method (6 lines removed)
  • Change confirmMutatingOperation visibility from private to public

packages/cli/src/commands/api/index.ts

  • Add confirmMutatingOperation() call at the start of executeSingleRequest()
  • Place it inside try-catch block for proper error handling

packages/cli/test/unit/util/client-confirmation.test.ts

  • Update all tests to call client.confirmMutatingOperation() directly
  • Remove mock endpoint setup (no longer needed)
  • Update assertions from response objects to boolean values

Testing

  • All 15 unit tests pass
  • vercel env rm now works with --yes flag in CI/CD environments
  • vercel api -X DELETE still prompts for confirmation as intended

Related

## Problem

PR vercel#14769 introduced a DELETE confirmation prompt for AI agent safety,
but incorrectly placed the `confirmMutatingOperation()` call inside
`client.fetch()`. This caused ALL commands using DELETE API calls
(e.g., `vercel env rm`, `vercel remove`) to fail in non-TTY environments
(CI/CD pipelines) because:

1. `confirmMutatingOperation()` was called on every `client.fetch()` with DELETE method
2. In non-TTY mode, it requires `--dangerously-skip-permissions` flag to proceed
3. But this flag was only added to the `vercel api` command
4. Other commands like `env rm` have their own `--yes` flag for confirmation,
   which became ineffective

## Solution

Move the DELETE confirmation logic to only apply to `vercel api` command:

1. Remove `confirmMutatingOperation()` call from `client.fetch()`
2. Change `confirmMutatingOperation()` from private to public method
3. Call `confirmMutatingOperation()` directly in `vercel api`'s `executeSingleRequest()`
4. Update tests to call `confirmMutatingOperation()` directly instead of through `fetch()`

## Changes

- `packages/cli/src/util/client.ts`:
  - Remove confirmation call from `fetch()` method (6 lines removed)
  - Change `confirmMutatingOperation` visibility from `private` to `public`

- `packages/cli/src/commands/api/index.ts`:
  - Add `confirmMutatingOperation()` call at the start of `executeSingleRequest()`
  - Place it inside try-catch block for proper error handling

- `packages/cli/test/unit/util/client-confirmation.test.ts`:
  - Update all tests to call `client.confirmMutatingOperation()` directly
  - Remove mock endpoint setup (no longer needed)
  - Update assertions from response objects to boolean values

## Testing

- All 15 unit tests pass
- `vercel env rm` now works with `--yes` flag in CI/CD environments
- `vercel api -X DELETE` still prompts for confirmation as intended

Fixes commands failing in CI with error:
"DELETE operations require confirmation. Use --dangerously-skip-permissions
to skip confirmation in non-interactive mode."
@developerjhp developerjhp requested a review from a team as a code owner January 29, 2026 11:34
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: 72c543e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

DELETE confirmation is bypassed when using --paginate flag with the vercel api command

Fix on Vercel

tknickman added a commit that referenced this pull request Jan 29, 2026
…ly (#14787)

## Summary

Fixes a regression from #14769 where the DELETE confirmation prompt was
incorrectly applied to **all** DELETE operations instead of only the
`vercel api` command.

This was breaking CI/CD pipelines that use commands like:
- `vercel env rm <name> --yes`
- `vercel alias rm <alias> --yes`
- `vercel remove <deployment> --yes`

These commands have their own `--yes` flags for confirmation and should
not be affected by the new `--dangerously-skip-permissions` flag which
was designed specifically for the `vercel api` command.

## Changes

- **`packages/cli/src/util/client.ts`**: Made
`confirmMutatingOperation()` public and removed the call from `fetch()`
method
- **`packages/cli/src/commands/api/index.ts`**: Added
`confirmMutatingOperation()` calls in `executeSingleRequest()` and
`executePaginatedRequest()` - scoping confirmation to only the `vercel
api` command
- **`packages/cli/test/mocks/client.ts`**: Removed workaround that set
`dangerouslySkipPermissions = true` by default
- **`packages/cli/test/unit/util/client-confirmation.test.ts`**: Updated
tests to call `confirmMutatingOperation()` directly

## Test plan

- [x] All 15 unit tests pass
- [x] TypeScript compiles without errors
- [x] `vercel env rm --yes` works in non-TTY mode (no longer blocked)
- [x] `vercel api -X DELETE` still prompts for confirmation as intended

## Related

- Fixes regression introduced in #14769
- Supersedes #14784

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@tknickman
Copy link
Copy Markdown
Member

Thanks for the fix! I pulled this in and shipped as part of vercel@50.9.2

@tknickman tknickman closed this Jan 29, 2026
adriancooney pushed a commit that referenced this pull request Jan 30, 2026
…ly (#14787)

## Summary

Fixes a regression from #14769 where the DELETE confirmation prompt was
incorrectly applied to **all** DELETE operations instead of only the
`vercel api` command.

This was breaking CI/CD pipelines that use commands like:
- `vercel env rm <name> --yes`
- `vercel alias rm <alias> --yes`
- `vercel remove <deployment> --yes`

These commands have their own `--yes` flags for confirmation and should
not be affected by the new `--dangerously-skip-permissions` flag which
was designed specifically for the `vercel api` command.

## Changes

- **`packages/cli/src/util/client.ts`**: Made
`confirmMutatingOperation()` public and removed the call from `fetch()`
method
- **`packages/cli/src/commands/api/index.ts`**: Added
`confirmMutatingOperation()` calls in `executeSingleRequest()` and
`executePaginatedRequest()` - scoping confirmation to only the `vercel
api` command
- **`packages/cli/test/mocks/client.ts`**: Removed workaround that set
`dangerouslySkipPermissions = true` by default
- **`packages/cli/test/unit/util/client-confirmation.test.ts`**: Updated
tests to call `confirmMutatingOperation()` directly

## Test plan

- [x] All 15 unit tests pass
- [x] TypeScript compiles without errors
- [x] `vercel env rm --yes` works in non-TTY mode (no longer blocked)
- [x] `vercel api -X DELETE` still prompts for confirmation as intended

## Related

- Fixes regression introduced in #14769
- Supersedes #14784

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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