TML-3099: framework tail onto structured codes; codec boundaries pass structured envelopes - #1063
Conversation
…r codes Pack-contribution and authoring-argument defects in framework-authoring raise CONTRACT.PACK_CONTRIBUTION_INVALID / CONTRACT.ARGUMENT_INVALID via the existing runtimeError helper; entity hydration, execution-requirement, and schema-diff sites join the published codes; invariants become InternalError. Messages preserved byte-for-byte. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
…e codes TS contract loading raises the new CONTRACT.EXPORT_INVALID / SOURCE_LOAD_FAILED / SOURCE_IMPORT_DISALLOWED; control-client lifecycle reuses DRIVER/CONFIG/MIGRATION codes; the CLI-internal ContractValidationError class folds into CONTRACT.VALIDATION_FAILED. The hidden telemetry crash-test throw stays bare by design. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Deletes ConfigValidationError, ConfigFileNotFoundError, and DomainNamespaceResolutionError; their failures raise CONFIG.VALIDATION_FAILED / CONFIG.FILE_NOT_FOUND / CONTRACT.NAMESPACE_INVALID. Mints PSL.FORMAT_OPTION_INVALID and MIGRATION.DESCRIBE_INVALID; converts the remaining fw emitter, ts-render, operations, and migration-tools sites; the canonical-stringify TypeErrors stay by design. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
The SQL emitter and 9-family contract paths raise published CONTRACT codes; builder-DSL misuse reuses ORM.* codes; codec helpers follow the hook direction. The runtime codec boundaries pass through any isStructuredError envelope (previously isRuntimeError only), so structured extension-codec errors are no longer re-wrapped under a same-code wrapper. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Mongo emitter/foundation/family contract paths raise published CONTRACT codes; query-ast/query-builder DSL misuse reuses ORM.* (RangeErrors included); the mongo decode boundary gains a structured-envelope pass-through and the adapter encode boundary widens its exact-code check to isStructuredError; the two mongo-driver switch fallbacks become assertNever. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Adds the five new code entries, widens the ORM namespace prose to cover the query-builder DSLs and the DRIVER lifecycle entries to cover the CLI control client, and records framework-error-classes-removed in both 0.16-to-0.17 recipes. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
|
Important Review skippedToo many files! This PR contains 143 files, which is 43 over the limit of 100. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (148)
You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/config-loader
@prisma-next/emitter
@prisma-next/language-server
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
size-limit report 📦
|
The exemption expired 2026-07-26, failing the Coverage job on any PR opened after that date. The justification is unchanged (files exercised by the cross-package adapter/e2e suites outside the per-package coverage scope); renewed for another 90 days with the recovery options restated. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
The ConfigValidationError fold left the no-field/no-why mapping fallbacks in load.ts uncovered (94% branches, under the 95% threshold); one test through the real mapper covers both. Signed-off-by: willbot <w.a.madden+machine@gmail.com> Signed-off-by: Will Madden <madden@prisma.io>
Linked issue
Refs TML-3099 (error consolidation slice 6 — the final sweep slice, under umbrella TML-3067). Follows the adapters/targets sweep (#1049) and the extensions sweep (#1053).
At a glance
Before this PR the framework core, CLI, SQL, and Mongo planes still carried ~250 bare
throw new Error(...)sites. This slice finishes the sweep: the repo-wide bare-throw ratchet lands at 47 (examples/demo apps plus a handful of deliberate keeps), down from ~538 when the effort started. Every message string is preserved byte-for-byte.Decision
The final error-consolidation slice puts the framework tail onto the ADR 239 scheme and closes the boundary follow-up from #1053:
1-framework(105),2-sql(71), and2-mongo-family(60), plus the two mongo-driver switch fallbacks: 199 structured (186 reusing 40 published codes), 42InternalError, 5assertNever, 6 deliberate keeps.CONTRACT.EXPORT_INVALID/SOURCE_LOAD_FAILED/SOURCE_IMPORT_DISALLOWED(CLI TypeScript-contract loading),MIGRATION.DESCRIBE_INVALID,PSL.FORMAT_OPTION_INVALID.ContractValidationError(non-breaking) and three exported classes —ConfigValidationError,ConfigFileNotFoundError,DomainNamespaceResolutionError— whose removal is recorded asframework-error-classes-removedin both 0.16→0.17 upgrade recipes. Eight other classes were audited and deliberately kept (the mechanism classes, two already-structured ones, internal control-flow tokens, the driver transport surface).isRuntimeErrortoisStructuredError, the mongo decode boundary gains a pass-through it never had, and the mongo adapter's encode boundary drops its exact-code check — structured extension-codec errors are no longer nested under a same-code wrapper (the follow-up flagged in TML-3092: extensions plane onto structured codes; Supabase error classes fold #1053).ORM.*(ARGUMENT_INVALID,COLUMN_UNKNOWN,MUTATION_DATA_MISSING, …) — the namespace's reference prose is widened from "ORM client API misuse" to cover thesql()and Mongo query-builder DSLs, mirroring how TML-3092: extensions plane onto structured codes; Supabase error classes fold #1053 widenedDRIVER.*for facade clients.Reviewer notes
CONTRACT.VALIDATION_FAILEDemit-validation sites (SQL + Mongo emitters), the 36CONTRACT.PACK_CONTRIBUTION_INVALIDcontribution-shape sites (mostly one repetitive file,framework-authoring.ts), and the 47ORM.*builder-DSL sites. Everything else is small.__telemetry-crash-testCLI command (it exists to produce an unstructured crash for the telemetry e2e) and the fivecanonical-stringifyTypeErrors (genuine type violations in a generic utility; ADR 239 exempts them). These are the in-scope ratchet floor.FilteredCollection/FilteredBuilderempty-filter throws becameInternalErrorafter an empirical reachability check (every public.match()path seeds one filter). Both classes are technically exported with public constructors, so a hand-constructed instance with[]gets anInternalErrorrather than a structured code — accepted, since no builder-API path reaches it.CONTRACT.MARKER_ROW_CORRUPTfold in sql 9-family keeps itsInvalid contract marker row:message prefix — the framework's marker-read error detection matches on it.result.ok=falseflake surfaced in 4 CLI progress-emission tests only under full-workspace parallelism (esbuild bundling in tmp dirs under load); green in isolation and on a full-suite rerun.Behavior changes & evidence
isStructuredError(e) && e.code === '…'; messages unchanged. Implementation: per-package local unions and factories, e.g. cli load-ts-contract.ts, sql emitter errors.ts. Evidence: per-code assertions through real throw paths in each package (e.g. cli client.errors.test.ts, 9-family contract-to-schema-ir.error-codes.test.ts).Errors still get the boundary's table/column meta.CliStructuredErrorfactories); onlyinstanceofconsumers notice. Evidence: to-structured-config-error.test.ts; recipe entry in the user recipe.Compatibility / migration / risk
Adding codes to codeless throws is non-breaking. Breaking: the three exported class deletions, covered by the
framework-error-classes-removedrecipe entry in both recipes. Mongoquery-astRangeErrors became structuredErrors (message-compatible). Ratchet: 284 → 47 (−237); cumulative for the effort: ~538 → 47.Testing performed
pnpm build,pnpm typecheck,pnpm lint,pnpm lint:deps,pnpm lint:skills,pnpm fixtures:check— green (re-run after rebasing onto TML-2988: Hard-cut @db.* lowering; add actionable diagnostics #1054)pnpm check:error-reference— all 244 published codes documented;pnpm check:upgrade-coverage --mode pr,pnpm lint:throws(−237) — greenpnpm test:packages— 13785 passed (4 esbuild-under-load flakes in CLI progress tests, green in isolation and on full-suite rerun)pnpm test:integration,pnpm test:e2e— greenFollow-ups
DOCS_ERRORS_VERSIONnext→v8; centralize hardcodedprisma-next.devURLs ontodocsUrlFor.Results;LINT.SELECT_STARseverity divergence between AST and raw paths.Alternatives considered
PLAN.*codes for builder-DSL misuse — reusedORM.*with widened prose instead: the published entries match these conditions word-for-word, andPLANmeans plan constraints at execution, not authoring-time API misuse.MigrationToolsErrorand the foundationContractValidationErrortoo — kept: both already carry dotted codes and satisfyisStructuredError; folding them is churn without user-visible benefit.error.code, neverinstanceof, all consumers are in-repo, and pre-RC is the time.Checklist
TML-NNNN: <sentence>