Repository navigation
fix(service): delete, rollback and domain delete name their branch before you confirm, from the platform's branch list - #410
Merged
Conversation
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>
|
Warning Review limit reachedThis 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. View limit details
|
commit: |
wmadden
approved these changes
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
service delete,service version rollbackandservice domain deletenow name the branch they will act on before you confirm, and say when it is production. To do that, everyservicecommand run with--branchnow asks the platform about that branch, where it used to guess from the name.A project whose default branch is
trunkalso has a preview branch namedmain. Inprisma@8.0.0-rc.36:rc.35 deleted the
apiservice onmainhere. rc.36 deletes the one ontrunk, with the same question. With this change:The id in brackets is the service's id.
The problem
Each project has branches, such as
mainorfeature/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
servicecommand without--branchnow acts on the default branch. In rc.35 it acted on the branch namedmain. 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
--confirmstops withCLI.CONSENT_REQUIRED, and the error'swhyis 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 everyservicecommand run with--branchnow finds the branch in the project's branch list. It takes from the platform whether the branch is the default, and its role, which isproductionorpreview. Before, the CLI guessed the role from the name:mainwas always production.If the project has no branch with that name, the name is used as typed, so
service create --branch new-featurestill creates the branch. Such a branch is never the default, so a question names it ason branch new-feature. A service named by address needs no extra request, because the address lookup already found the branch.What users see change
service deleteandservice version rollbackreturn the branch:branchin JSON and abranchrow in human output.service domain deletealready did.service deletesummary reads "Deleted api and every version it owned from branch trunk."service delete--branchhelp now says "(default: the default branch)", the wording the otherservicecommands already use.service domainresults report the branch's role from the platform. With--branch mainon a project wheremainis a preview branch,kindis nowpreview, notproduction.servicecommand run with--branchmakes one more request. If it fails, the command stops withBRANCH.API_ERRORand does nothing, where before it went ahead.Tests
trunkwith a preview branch namedmain. For all three commands, the question and the result nametrunkand say production.--branch maindoes not say production;--branch trunkdoes. These tests fail if the CLI takes the literalmain, or never says production.service create --branch featureon a project without that branch creates it.--branchstopsservice deletebefore any delete request.service deleteonmainwithout--confirm, checks that the refusal saysin 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
--branchis still used as typed.service delete api --branch produtionthen says the service does not exist, not the branch. Now that the CLI looks the branch up, it could say so, but that changesservice listand adds an error, so it gets its own pull request.postgres deleteandbucket deletequestions do not name a branch either. They do not pick the default branch for you the way theservicecommands do, so the case above, where the same command silently moved to another branch, does not arise there.Alternatives considered
--branchis left out. No extra request. But--branch trunkwould then get a milder question than no flag on the same branch.mainproduction, and miss the real production branch.--confirm <service>would break.Agent: amun-44