Skip to content

fix(service): delete, rollback and domain delete name their branch before you confirm, from the platform's branch list - #410

Merged
wmadden-electric merged 5 commits into
mainfrom
fix/delete-names-branch
Nov 27, 2026
Merged

wmadden-electric merged 5 commits into
mainfrom
fix/delete-names-branch

Conversation

@wmadden-electric

Copy link
Copy Markdown
Contributor

service delete, service version rollback and service domain delete now name the branch they will act on before you confirm, and say when it is production. To do that, every service command run with --branch now asks the platform about that branch, where it used to guess from the name.

A project whose default branch is trunk also has a preview branch named main. In prisma@8.0.0-rc.36:

$ npx prisma service delete api
Delete Service "api" and every version it owns?

rc.35 deleted the api service on main here. rc.36 deletes the one on trunk, with the same question. With this change:

$ npx prisma service delete api
Delete Service "api" (svc_2f9…) in production (branch trunk) and every version it owns?

$ npx prisma service delete api --branch main
Delete Service "api" (svc_8c1…) on branch main and every version it owns?

The id in brackets is the service's id.

The problem

Each project has branches, such as main or feature/login. The platform marks one of them as the project's default branch, which serves production.

You confirm a deletion by typing the service's name. The same name can exist on several branches, so the question has to say which branch it means. Today it does not, unless you named the service by address.

This matters more since rc.36 (#404). A service command without --branch now acts on the default branch. In rc.35 it acted on the branch named main. So in a project like the one above, the same command now deletes a different service, and the question does not show it. CodeRabbit pointed this out on the rc.36 release pull request (#409).

The decision

The three commands name the branch in their confirmation question. On the default branch, it says in production (branch trunk); on any other, on branch feature. This is the wording they already used for a service named by address, written @<branch>:<project>.<service>, such as @pr-42:shop.api.

Scripts and agents see the question too. A run without --confirm stops with CLI.CONSENT_REQUIRED, and the error's why is the question, so the branch is shown before anything is deleted.

The CLI asks the platform about the branch you name

To say production when you pass --branch, the CLI must know whether that branch is the default. So every service command run with --branch now finds the branch in the project's branch list. It takes from the platform whether the branch is the default, and its role, which is production or preview. Before, the CLI guessed the role from the name: main was always production.

If the project has no branch with that name, the name is used as typed, so service create --branch new-feature still creates the branch. Such a branch is never the default, so a question names it as on branch new-feature. A service named by address needs no extra request, because the address lookup already found the branch.

What users see change

  • The three questions name the service id and the branch, and say production on the default branch.
  • service delete and service version rollback return the branch: branch in JSON and a branch row in human output. service domain delete already did.
  • The service delete summary reads "Deleted api and every version it owned from branch trunk."
  • The service delete --branch help now says "(default: the default branch)", the wording the other service commands already use.
  • JSON change scripts may see: service domain results report the branch's role from the platform. With --branch main on a project where main is a preview branch, kind is now preview, not production.
  • New failure: every service command run with --branch makes one more request. If it fails, the command stops with BRANCH.API_ERROR and does nothing, where before it went ahead.

Tests

  • Against the fake management API, a project whose default branch is trunk with a preview branch named main. For all three commands, the question and the result name trunk and say production. --branch main does not say production; --branch trunk does. These tests fail if the CLI takes the literal main, or never says production.
  • service create --branch feature on a project without that branch creates it.
  • A failing branch listing under --branch stops service delete before any delete request.
  • A delete given an address makes one branch-list request, not two.
  • A new real-API case runs service delete on main without --confirm, checks that the refusal says in production (branch main), and checks that the service still exists.

Only the changed test files, the typecheck and lint were run locally. CI runs the rest.

Not in this pull request

  • A mistyped --branch is still used as typed. service delete api --branch prodution then says the service does not exist, not the branch. Now that the CLI looks the branch up, it could say so, but that changes service list and adds an error, so it gets its own pull request.
  • The postgres delete and bucket delete questions do not name a branch either. They do not pick the default branch for you the way the service commands do, so the case above, where the same command silently moved to another branch, does not arise there.

Alternatives considered

  • Name the branch only when --branch is left out. No extra request. But --branch trunk would then get a milder question than no flag on the same branch.
  • Keep guessing the role from the name. No extra request, but the CLI would call a preview main production, and miss the real production branch.
  • Make the branch part of the confirmation token. You would type the branch, but every script that passes --confirm <service> would break.

Agent: amun-44

A bare service name is now resolved on the project's default branch, so the confirmation, the consent-required error and the result say which branch the service is deleted from.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…ault branch

service delete, service version rollback and service domain delete now name the branch in their confirmation question (also the why of CLI.CONSENT_REQUIRED), and say "in production" when the branch is the project's default, as the address form does. The resolved branch carries isDefault from the branch listing; with --branch it is false, since no lookup is made. service delete's JSON branch is now a string, like service create and service list, and service version rollback's result gains the same branch field. The delete summary reads "Deleted <name> and every version it owned from branch <branch>." and its --branch brief states the default. Tests use a project whose default branch is trunk with a preview branch named main.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
With --branch, the CLI now finds the named branch in the project's branch listing and takes its id, role and default mark from it, so --branch trunk on a project whose default is trunk says production, and the branch kind in domain results comes from the API instead of a guess from the git name. A name the project does not list is used as typed, so service create --branch <name> still creates it. Adds tests for --branch naming the default branch, for the listed kind, and for service version rollback by address.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…okup's edges

A service named by address now takes its branch (id, git name, role, default mark) from the address resolution instead of listing the project's branches a second time; AddressMatch.branch gains role for this. Adds unit tests for service create --branch with a name the project lacks (the branch is created under that name), for a failed branch listing under --branch (BRANCH.API_ERROR, nothing deleted), and for an address listing branches once, plus an end-to-end case where service delete --branch main without --confirm is refused and its question says production.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…ot both

resolveServiceProjectContext and resolveServiceProjectState now take either a --branch name or a branch an address already resolved, as a union, so both cannot be passed. AddressMatch.branch is the BranchRecord the listing returns, and one converter turns a listed branch into the resolved service branch for both the --branch lookup and the address path. No behaviour change.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 458f1c01-8b0d-44d5-93b8-93d1bba2d2ac
Commits

Reviewing files that changed from the base of the PR and between b375612 and 59f1100.

Files selected for processing: 16

  • docs/product/command-principles.md
  • packages/cli/e2e/service.e2e.ts
  • packages/cli/src/commands/service/delete.ts
  • packages/cli/src/commands/service/domain-delete.ts
  • packages/cli/src/commands/service/presentation.ts
  • packages/cli/src/commands/service/results.ts
  • packages/cli/src/commands/service/target.ts
  • packages/cli/src/commands/service/version-rollback.ts
  • packages/cli/src/lib/address/address.ts
  • packages/cli/tests/address.test.ts
  • packages/cli/tests/service-address.test.ts
  • packages/cli/tests/service-create.test.ts
  • packages/cli/tests/service-delete.test.ts
  • packages/cli/tests/service-domain.test.ts
  • packages/cli/tests/service-testkit.ts
  • packages/cli/tests/service-version-rollback.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@pkg-pr-new

pkg-pr-new Bot commented Nov 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@prisma/cli@410
npx https://pkg.pr.new/@prisma/cli-engine@410

commit: 59f1100

@wmadden-electric
wmadden-electric merged commit 114b1ec into main Nov 27, 2026
16 checks passed
@wmadden-electric
wmadden-electric deleted the fix/delete-names-branch branch November 27, 2026 08:09
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