Skip to content

TML-3900: Both consent errors open with the same plain sentence - #398

Merged
wmadden-electric merged 3 commits into
mainfrom
consent-confirm-first-line
Nov 23, 2026
Merged

wmadden-electric merged 3 commits into
mainfrom
consent-confirm-first-line

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

A user runs prisma postgres delete @shop.catalog in a script. Deleting a database needs the user's consent, and in a script nobody can type it, so the command stops with an error.

Before:

✘ [CLI.CONSENT_REQUIRED] "Deleting database db_catalog_main in production (branch main) is destructive and requires the exact address." requires explicit consent, and the session is not interactive. Grant it by passing --confirm @shop.catalog.
→ Run the command interactively and type @shop.catalog, or pass --confirm @shop.catalog.

After:

✘ [CLI.CONSENT_REQUIRED] This command requires explicit consent, but it was not provided.
  why: Deleting database db_catalog_main in production (branch main) is destructive and requires the exact address.
→ Run the command interactively and type @shop.catalog, or pass --confirm @shop.catalog.

Why

The engine raises CLI.CONSENT_REQUIRED from two places:

  • a yes/no consent, such as the one above, which --confirm <token> can answer;
  • a question that only a flag such as --delete Legacy can answer.

#397 gave the second one a plain first line: This command requires explicit consent, but it was not provided. The first one kept its old line, so one error code opened with two different sentences. The old line also packed three things into one sentence: the command's question, the phrase "the session is not interactive", and the fix.

Every CLI error has the same three parts: the first line says what failed, why gives the cause, and the next lines say what to do. This change puts each piece in its part.

The change

In consentUnavailable (packages/cli-engine/src/execution/prompts.ts):

  • The first line is the same fixed sentence as the other consent error. Both now take it from one function. Under --yes it reads This command requires explicit consent, and --yes does not give it.
  • The command's question moves to why, where the other consent error already puts its questions.
  • The first line no longer ends with Grant it by passing --confirm <token>. The next-step line already says that.

What stays the same

The error code, the exit code, the next-step lines and meta.consentToken. A script that reads those is unaffected. A script or test that searched the first line for the question or for --confirm <token> must read why or the next step instead; seven tests in packages/cli and one end-to-end test did, and they are updated here.

Version and conformance

@prisma/cli-engine goes from 0.10.2 to 0.10.3. Only error text moves, so it is a patch. @prisma/orm-toolchain and @prisma/composer-cli still require engine 0.10.0, so the two exceptions in packages/cli/scripts/conformance.ts that #397 set to 0.10.2 now name 0.10.3. They are still limited to the dev channel: a CLI release is refused until both products require 0.10.3, and the pull request that pins those product releases removes the exceptions.

Not in this change

A user who passes the wrong token, --confirm staging-db where prod-db is expected, is told consent "was not provided". The next step names the right token, but nothing names the one they passed. The old text did not name it either.

Alternatives considered

  • Keep the question in the first line. "Deleting database … is destructive and requires the exact address." requires explicit consent makes the first line as long as the question and keeps the two consent errors different.
  • Leave it for later. The two errors share a code, and products are about to move to the engine version that changed one of them. Doing both now means products take one new sentence, once.

Agent: hammurabi-19

…e as the one for a missing statement flag

The first line no longer quotes the question or says "the session is not interactive". The question moves to `why`, where the statement refusal already puts its questions. Engine 0.10.3.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…question in why and its next action

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary by CodeRabbit

  • Bug Fixes
    • Consent-related CLI errors now present a consistent summary, with the specific prompt in the explanation and confirmation guidance in the recovery actions.
    • Error details distinguish missing explicit consent from the consent question, including when --yes is used without a required confirmation token.

Walkthrough

The CLI engine now uses a shared consent-required summary and places the consent question in the error’s why field. Confirmation-token guidance appears in nextActions, with the token recorded in metadata when present. Tests and CLI consumers now check these error fields. Scratch-project teardown adds the why detail to its warning when available. Documentation, package versions, and conformance pins are updated.

Merge Risk: Minimal · up to e2abf

This change rewords the consent-required error and moves the consent question into its why field. Scripts that read the first line for the question or the --confirm token must now read why or the next-step line. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change, which makes both consent errors open with the same plain sentence. The description and summary confirm this: consentUnavailable now uses the same fixed first line as t…
Description check Passed The description states the problem, the before and after error output, the reason for the change, the files touched, the version bump, the conformance exceptions, and the known gap with wrong tokens. …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change, which makes both consent errors open with the same plain sentence. The description and summary confirm this: consentUnavailable now uses the same fixed first line as the other consent error, and the question moves to why. The ticket prefix is a minor style point and does not affect the assessment.

Full details: Description check

Explanation

The description states the problem, the before and after error output, the reason for the change, the files touched, the version bump, the conformance exceptions, and the known gap with wrong tokens. It matches the changeset closely.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

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: 1dc07109-47d5-40e3-9950-5f0c92d927ea
Commits

Reviewing files that changed from the base of the PR and between e30163a and e2abfcf.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 16

  • docs/reference/error-reference.md
  • packages/cli-engine/package.json
  • packages/cli-engine/src/execution/prompts.ts
  • packages/cli-engine/tests/interaction-affordances.test.ts
  • packages/cli-engine/tests/prompts.test.ts
  • packages/cli/e2e/address.e2e.ts
  • packages/cli/e2e/scratch.ts
  • packages/cli/package.json
  • packages/cli/scripts/conformance.ts
  • packages/cli/tests/bucket.test.ts
  • packages/cli/tests/postgres.test.ts
  • packages/cli/tests/project.test.ts
  • packages/cli/tests/service-address.test.ts
  • packages/cli/tests/service-domain.test.ts
  • packages/cli/tests/service-version-rollback.test.ts
  • packages/prisma/package.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: e2abfcf

@wmadden-electric
wmadden-electric marked this pull request as ready for review November 23, 2026 03:59
@wmadden-electric
wmadden-electric merged commit fc95f03 into main Nov 23, 2026
18 of 19 checks passed
@wmadden-electric
wmadden-electric deleted the consent-confirm-first-line branch November 23, 2026 04:03
rome-xi pushed a commit to rome-xi/orm that referenced this pull request Nov 23, 2026
…ys so in plain words (prisma#31179)

A user removes the field `legacy` from the model `Shop` and runs `prisma
migration plan` in a script. The plan would drop a column that holds
data, so the command stops with an error.

Before:

```text
✘ [CLI.CONSENT_REQUIRED] "Shop.legacy" needs a statement, and the session is not interactive.
  why: Drop column "legacy" from "Store Front" would lose the values of field "Shop.legacy".
→ Run the command again with --rename Shop.legacy:Shop.rating
→ Run the command again with --delete Shop.legacy
```

After:

```text
✘ [CLI.CONSENT_REQUIRED] This command requires explicit consent, but it was not provided.
  why: Drop column "legacy" from "Store Front" would lose the values of field "Shop.legacy".
→ Run the command again with --rename Shop.legacy:Shop.rating
→ Run the command again with --delete Shop.legacy
```

Only the first line changes.

## Why the first line was a problem

When a change would lose data, the command asks the user what they
intend: is the field renamed, or deleted? In a terminal it asks with a
prompt. In a script nobody can answer a prompt, so the user answers with
a flag, `--rename` or `--delete`. If no flag answers the question, the
command stops with the error above.

The old first line described this in the CLI's internal vocabulary.
"Statement" is the internal name for an answer given by flag, and "the
session is not interactive" means the command could not show a prompt. A
user who has never met either term could not tell from the line what
went wrong.

The new first line says what failed in plain words: the command needs
the user's consent and did not get it. The `why` line already says what
would be lost, and the next lines already give the exact flags, so those
stay as they are.

## The change

The ORM does not write the first line. It comes from
`@prisma/cli-engine`, the library in prisma/prisma-cli that every Prisma
CLI command runs on. Two engine changes reword it: prisma/prisma-cli#397
for the error above, and prisma/prisma-cli#398 for the engine's other
consent error (see below). A third, prisma/prisma-cli#399, rewords the
`--yes` form of the sentence. All three are in engine 0.10.4. This pull
request moves the ORM from engine 0.10.0 to 0.10.4 and updates what
depended on the old text:

- 33 `package.json` files pin the engine at 0.10.4, and the lockfile
follows.
- The tests that assert the first line now assert the new one: two unit
test files and 12 CLI journey test files.
- An upgrade note under
`upgrade-instructions/pending/cli-engine-0-10-4/` tells app and
extension authors what to do if their scripts or tests matched the old
line.

No ORM source file changes.

## The other case: `--yes`

`--yes` accepts ordinary confirmations, but it does not answer a
question about losing data. In that case the old first line ended `which
--yes cannot give`. It now reads:

```text
✘ [CLI.CONSENT_REQUIRED] This command requires explicit consent for which --yes is not sufficient.
```

## The other consent error: `--confirm`

The engine has a second error with the same code, for a yes/no consent
that `--confirm <token>` answers. `prisma init` raises it when it would
replace an existing project. Its first line used to quote the question.
It now opens with the same sentence, and the question is in `why`:

```text
✘ [CLI.CONSENT_REQUIRED] This command requires explicit consent, but it was not provided.
  why: <the command's question>
→ Run the command interactively and type <token>, or pass --confirm <token>.
```

Two `prisma init` tests read the question from that first line; they now
read it from `why`. The upgrade note covers both errors.

## What stays the same

The error code, the exit code, the next-step lines and the error's
`meta` in `--json` output. A script that reads any of those is
unaffected. For the first error the `why` line is unchanged too.

The first line used to name the subject (`"Shop.legacy"`), and it is now
a fixed sentence. The subject is still in `meta.unanswered`, and the
upgrade note points there. Tests in this repository that read the
subject from the first line now read it from `meta.unanswered`.

## Also in this pull request

Two project documents for the work on stating intent for destructive
changes. Neither affects behaviour.

- `projects/migration-statements/spec.md`: its example error is now the
real output, and it links the terms it uses to the CLI style guide.
- `projects/migration-statements/deferred.md`: records problems with
these errors that manual testing and review found, for later work. They
behave the same on `main`.

## Alternatives considered

- **Rewrite the line inside the ORM.** The ORM could catch the engine's
error and replace the first line. Every other product on the engine
would keep the old line, and the ORM would carry a patch over its own
dependency. The sentence is fixed where it is written.
- **Put the data-loss sentence on the first line.** An earlier engine
release, 0.10.1, moved the `why` text up to the first line and wrote a
new generic `why`. Every CLI error has the same three parts: the first
line says what failed, `why` gives the cause, and the next lines say
what to do. That version moved the cause out of its place. Engine 0.10.2
replaced it, and nothing here uses it.
- **Keep the subject in the first line.** A sentence such as
`"Shop.legacy" requires explicit consent` reads badly when several
questions are unanswered, and the `why` line already names each subject.

Fixes TML-3900.

Agent: hammurabi-19

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
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.

1 participant