Repository navigation
fix(service): fail with SERVICE.BRANCH_NOT_FOUND when --branch names a branch the project does not have - #414
Merged
Merged
Conversation
…RANCH_NOT_FOUND Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…the advice first Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
wmadden-electric
marked this pull request as ready for review
November 30, 2026 00:49
commit: |
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.
A
servicecommand given a--branchthe project does not have now says the branch is missing. Before, it said the service was missing.Take a mistyped
production:$ prisma service delete api --branch prodution --jsonprisma@8.0.0-rc.36service delete api --branch produtionSERVICE.SELECTION_INVALID: "The requested service does not exist in the resolved project", exit 2SERVICE.BRANCH_NOT_FOUND, exit 2service list --branch produtionSERVICE.BRANCH_NOT_FOUND, exit 2The new error, as
--jsonreports it:{ "code": "SERVICE.BRANCH_NOT_FOUND", "summary": "Project \"shop\" has no branch named \"prodution\"", "why": "Project \"shop\" (proj_1) has no branch named \"prodution\". The name may be mistyped, or the branch may have been deleted.", "nextActions": [ { "kind": "user-choice", "label": "Pass --branch with the name of a branch the project has, or omit it to use the default branch." }, { "kind": "run-command", "label": "List the project's branches", "command": "prisma branch list --project proj_1" } ], "meta": { "projectId": "proj_1", "branchName": "prodution" } }Breaking change for scripts:
service list --branch <a branch that does not exist>used to print an empty list and exit 0. It now fails with exit code 2.What went wrong before
Each project has branches, such as
mainorfeature/login, and a service runs on one branch. Aservicecommand acts on the project's default branch, or on the branch--branchnames.#410 made the confirmation questions of destructive commands say "production" when they act on the default branch. To know that, every
servicecommand run with--branchnow looks the name up in the project's branch list. When the list had no branch with that name, the CLI still went on with the name as typed. The management API then found no service on that branch, so the CLI reported a missing service, andservice listreported no services.The decision
When the lookup finds no branch with that name, the command stops at once with
SERVICE.BRANCH_NOT_FOUND, before it lists or changes any service. The environment variable commands already do the same:prisma project env list --branch <missing>fails withPROJECT.ENV_BRANCH_NOT_FOUND.service createis the one exception. Creating a service on a branch the project does not have creates that branch, so it still takes the name as typed. The check is on by default in the shared lookup, andservice createturns it off with theacceptsUnlistedBranchoption. A newservicecommand therefore gets the check without having to ask for it.A service named by its address is not affected. An address, such as
@pr-42:shop.api, names the branch, the project and the service in one string. Its lookup already finds the branch, and reports its own error when the branch is missing.The commands that now fail on a missing branch are
service list,service show,service open,service logs,service delete,service version list,service version rollback, andservice domain add,show,wait,retryanddelete.Tests
--branch produtionon a project without that branch:service list,service deleteand each of the fiveservice domaincommands fail with the new error, exit code 2 and themetaabove, and make no request to list services.service deletealso makes no delete request. Theservice listtest checks the summary,whyand thebranch listnext action word for word.service create --branch <new>still creates the service on a new branch (an existing test).service list --branch <missing>and checks the code andmeta.stagingandfeature/foo, since an unlisted branch now fails.Only the changed test files, the typecheck and lint were run locally. CI runs the rest.
Not in this pull request
postgresandbucketcommands report a mistyped--branchbadly too. They find branches through different code. The follow-up is one shared "find a branch by name" step forservice,postgres,bucketand addresses. It is recorded here only, not yet in a ticket.Alternatives considered
--branch, so this saves no request. Andservice listnever fails to find a service, so it would still print an empty list.service list, warn and still exit 0. This avoids the breaking change. But a script that lists a mistyped branch would still read "no services" and act on it, which is the problem this change fixes.Agent: amun-44