docs: add the canonical error-reference registry and completeness check - #234
Merged
Conversation
Mirrors prisma/prisma's error-reference pattern so docs.prisma.io can aggregate the CLI's structured errors: - docs/reference/error-reference.md documents all 128 NAMESPACE.SUBCODE codes in production source, by namespace, with the condition that raises each one - scripts/list-error-codes.mjs enumerates codes from source (json, markdown skeleton, and --verify modes, --root for external checkouts) - pnpm check:error-reference wired into pr-quality.yml: a new code cannot ship undocumented - the command families now set docsBaseUrl, so emitted errors carry docsUrl = https://www.prisma.io/docs/cli/error-reference/<CODE> (the docs site redirects the path form to the #<CODE> anchor) - CLI_DOCS_URL points at /docs/cli now that the unified CLI has its own docs section; update-check tests pin the new URL Known gap, deliberately out of scope: a few boundaries build codes dynamically (SERVICE.<LEGACY>, GIT.<RAW>, POSTGRES.<RAW>, BUCKET.<RAW> passthroughs), which a literal scanner cannot enumerate; the registry intro documents the passthrough rule instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
|
Warning Review limit reachedNext included review available in 19 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (77)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
wmadden
approved these changes
Aug 25, 2026
… layer The CLI carried two error systems: the engine's structured CliStructuredError, and an older flat-code CliError that per-domain boundary mappers rewrote into dotted codes on the way out. Two of those rewrites built codes by concatenation, which is how codes reached users that exist nowhere in source: - fromLegacyCliError prefixed SERVICE. onto whatever code it was handed, so an unmatched --project was SERVICE.PROJECT_AMBIGUOUS through a service command and PROJECT.AMBIGUOUS through a project command — two codes for one condition, one of them unlistable and unbranchable. - The API mappers used the server's own code as the error code, so a 403 surfaced as PROJECT.forbidden. A test had pinned that shape. Neither is a documentation problem, so neither is fixed by documenting it. Every raise site now constructs CliStructuredError with its registered code directly, and the layer that rewrote them is gone: - deleted src/errors.ts (CliError, usageError, authRequiredError, ...), src/next-actions.ts, and the five mappers under commands/*/errors.ts - removed the try/catch map-and-rethrow wrapper from every command handler; a thrown structured error settles itself - a failed Management API call raises the domain's registered *.API_ERROR with the API's code and status in meta.apiCode / meta.status - a 401/403 no longer mints an *.AUTH_REQUIRED code that never existed in source; it is the domain's API error plus an auth login next action - the legacy free-text fix is the first user-choice next action and nextSteps are run-command actions, built at the raise site; install URLs are open-url actions rather than commands Registry and conventions follow the code: the passthrough rule is deleted rather than described, two entries with no raise site are removed, and error-conventions.md states the two rules this enforces — assign the code at origin, and treat a server's code as data. The scanner also skips tracked-but-deleted files, so a branch mid-delete reports instead of crashing. SERVICE.PROJECT_NOT_FOUND deliberately survives: it is authored at a raise site for the services API refusing an already-resolved project, which is a different moment from a --project reference matching nothing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
wmadden-electric
added a commit
to prisma/web
that referenced
this pull request
Aug 25, 2026
prisma/prisma-cli#234 removed the code-rewriting boundary layer, so the registry no longer documents a passthrough rule and no longer carries the two entries that had no raise site. 128 codes -> 126. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
The docs site publishes this page and spell-checks it in US English, so four British spellings (recognised, unrecognised, recognises) are fixed at the source rather than dictionaried downstream. CLI.CONSENT_REQUIRED called consent "structurally undefaultable", an invented word for a simple fact: consent has no default answer and --yes does not grant it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
ankur-arch
added a commit
to prisma/web
that referenced
this pull request
Aug 25, 2026
* docs: aggregate CLI error codes from prisma/prisma-cli Extends the error-reference pipeline (generator + daily sync + completeness check) to a second source repo, following the same pattern used for prisma/prisma. The CLI gets its own page at /docs/cli/error-reference because the CLI.* namespace exists in both repos with different meanings (CLI.PROMPT_REQUIRED collides). - generate-error-reference.mjs takes --target orm|cli; orm output is unchanged - both workflows also check out prisma/prisma-cli and run its own scripts/list-error-codes.mjs to verify page completeness, exactly as they do with prisma/prisma's scanner - the generated CLI page (128 codes) is committed, with a sidebar entry under the CLI section's Introduction group - next.config.mjs redirects the path form …/error-reference/<CODE> to the #<CODE> anchor for both the ORM and CLI pages — the CLI engine composes docsUrls in path form from a family docsBaseUrl, and the ORM family's links were 404ing on this before Companion PR (must merge first): prisma/prisma-cli#234, which adds the canonical registry and scanner this consumes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io> * docs: regenerate the CLI error page after the upstream cleanup prisma/prisma-cli#234 removed the code-rewriting boundary layer, so the registry no longer documents a passthrough rule and no longer carries the two entries that had no raise site. 128 codes -> 126. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io> * docs: sync the ORM error reference with prisma/prisma main The completeness check caught real upstream drift: MIGRATION.PLAN_ORIGIN_UNKNOWN shipped in prisma/orm#30122 and the page had not been regenerated since. Also picks up wording changes in three existing entries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io> * docs: teach the spellchecker the CLI error page's real terms Two genuine names the dictionary lacked: stricli (the argument parser the engine wraps) and UNWRITABLE (part of the INIT.CONFIG_UNWRITABLE and INIT.PACKAGE_JSON_UNWRITABLE codes), alongside the existing UNLOADABLE and UNPARSEABLE entries. The page itself is regenerated after prisma/prisma-cli fixed four British spellings and one invented word at the source, rather than adding those to the dictionary here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io> * docs: publish the CLI error page with the site's REST API name The docs site does not reintroduce "Management API" in prose (see apps/docs/CLAUDE.md); prisma-cli uses that name because the SDK it calls through is literally `@prisma/management-api-sdk`, which is right in that repo. The generator already exists to bridge that kind of mismatch for the ORM target, so the CLI target gets the same treatment: 13 prose occurrences become "REST API". The rewrite skips fenced blocks and inline code spans, so identifiers keep their real names — the exception apps/docs/CLAUDE.md calls out. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io> * docs: treat every markdown code form as opaque in the generator The prose rewriter recognized only triple-backtick fences and single-backtick spans, so a tilde fence or a multi-backtick span would have had its contents rewritten — the identifiers the rewrite exists to protect. assertMdxSafe had the same blind spot from the other direction: a brace inside a tilde fence looked like unescaped MDX and would have failed the build for text that is only ever displayed. Both now read one CODE_SEGMENT covering backtick and tilde fences and spans of any delimiter length, and the rewriter walks matches instead of splitting, so it no longer depends on the pattern having exactly one capture group. Verified against both fence styles, one/two/three-backtick spans, and mixed prose; both pages regenerate byte-identically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> 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> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>
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.
Replicates prisma/prisma's error-reference pattern in this repo so the docs site can aggregate the unified CLI's structured errors — and removes the legacy error layer that made a complete registry impossible. Companion web PR follows (it consumes this registry and must merge after this).
The registry and its check
docs/reference/error-reference.md— the canonical registry: everyNAMESPACE.SUBCODEcode in production source across 11 namespaces (AUTH, BRANCH, BUCKET, CLI, FEEDBACK, GIT, INIT, POSTGRES, PROJECT, SERVICE, SKILLS), each entry stating the condition that raises it, the command or boundary, the fix where the source carries one, and itsmetafields. Warn-severity diagnostics that ride successful runs are labeled as such.scripts/list-error-codes.mjs— enumerates codes from git-tracked production source (mirror of prisma/prisma's scanner; closed namespace list; json / markdown-skeleton /--verifymodes;--rootlets the docs repo run it against a checkout). It skips tracked-but-deleted files, so a branch mid-delete reports instead of crashing.pnpm check:error-reference— wired intopr-quality.ymlas a required-check job: a new code cannot ship undocumented.docsBaseUrlset onplatformCommandFamilyandskillsCommandFamily, so emitted errors now carrydocsUrl = https://www.prisma.io/docs/cli/error-reference/<CODE>(the docs site redirects that path form to the#<CODE>anchor, same convention the ORM family uses).CLI_DOCS_URLalso moves from the docs root to/docs/cli, which now exists.Structured errors at origin: the legacy layer is gone
A registry is only as honest as the codes it can see, and a scanner reads string literals. The CLI had a second error system underneath — a legacy
CliErrorwith flat codes (PROJECT_AMBIGUOUS,DATABASE_API_ERROR) that per-domain boundary mappers rewrote into dotted codes on the way out. Two of those rewrites built codes by concatenation:fromLegacyCliErrorprefixedSERVICE.onto whatever code it was handed. A--projectthat matched nothing becameSERVICE.PROJECT_AMBIGUOUSthrough a service command andPROJECT.AMBIGUOUSthrough a project command — two codes for one condition, and the first appears nowhere in source, so neither the scanner nor the registry nor a caller could know it exists.PROJECT.forbidden— a lowercase code invented by a remote service. A test had pinned that shape.Both are deleted, along with the whole legacy layer:
CliStructuredErrorwith its registered code directly.packages/cli/src/errors.ts(theCliErrorclass,usageError,authRequiredError, …),next-actions.ts's parallelNextActiontype, and the five mapper modules (commands/{project,branch,bucket,postgres,git}/errors.ts) are gone or reduced to real factories.try { … } catch { const mapped = map…(error) }wrapper in every command handler is gone; structured errors settle themselves.*.API_ERRORwith the API's own code and status inmeta.apiCode/meta.status, where they are data a caller can read.*.AUTH_REQUIREDcode that never existed in source; it is the domain's API error withmeta.statusand anauth loginnext action.fixis now the firstuser-choicenext action, andnextStepscommand strings arerun-commandactions — the rendering the mappers produced, built at the raise site. Install URLs areopen-urlactions rather than commands.docs/product/error-conventions.mdloses its pre-dotted "MVP Error Codes" list and its stale JSON envelope example, and states the two rules this PR enforces: assign the code at origin, and treat a server's code as data.Deliberate remaining duplication
SERVICE.PROJECT_NOT_FOUNDsurvives as its own code: it is authored at a raise site, for the services API refusing a project that had already resolved. That is a different moment from a--projectreference matching nothing, which is nowPROJECT.NOT_FOUNDfrom every command. Worth a look if you would rather collapse the two.Verification
pnpm check:error-reference— registry and source agree exactly, in both directionspnpm typecheck,pnpm check:grammar, biome clean on touched files@prisma/clitest suite green; the tests that pinnedPROJECT.forbidden,GIT.AUTH_REQUIRED,PROJECT.AUTH_REQUIRED, andSERVICE.PROJECT_NOT_FOUNDfor an unmatched--projectwere pinning the invented codes and now pin the registered ones🤖 Generated with Claude Code