chore(stack): upgrade @byteslice/result 0.2 → 0.5#582
Conversation
0.5's `FailureOption` no longer accepts a bare `{ type }` shape — a failure
must be an `Error` or carry an `error: Error`. This aligns stack with
`@cipherstash/auth` 0.41 (which already ships 0.5's Result) and unblocks the
tracked byteslice migration.
- `EncryptionError` gains a required `error: Error` holding the originating
error; `type` / `message` / `code` are unchanged, so readers of
`result.failure.*` are unaffected.
- New `toEncryptionError(type, error, code?)` factory coerces any caught value
to a real `Error` (never an unchecked `as Error`) and derives the message;
all 27 hand-built failure literals across encryption/* + identity now route
through it.
Verified: `tsc` clean, `tsup` build clean, biome clean. Offline suites
(validation, wasm-inline strategy, cjs-require) pass; remaining suite failures
are the pre-existing live-integration tests that need local CipherStash creds.
🦋 Changeset detectedLatest commit: 19331ac The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reached
Next review available in: 30 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (16)
✨ 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 |
There was a problem hiding this comment.
Pull request overview
Upgrade @cipherstash/stack to @byteslice/result@0.5.0 by updating the EncryptionError failure shape to satisfy the new FailureOption requirements, and mechanically refactoring stack operations/identity flows to construct failures via a shared factory.
Changes:
- Bump
@byteslice/resultfrom0.2.0→0.5.0(package + lockfile). - Add
error: ErrortoEncryptionErrorand introducetoEncryptionError(type, error, code?)to safely coerce unknown thrown values. - Route operation/identity failure mapping through
toEncryptionErrorand add a Changeset for the minor release.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks @byteslice/result@0.5.0 for packages/stack. |
| packages/stack/package.json | Updates stack’s direct dependency pin to 0.5.0. |
| packages/stack/src/errors/index.ts | Updates EncryptionError contract and adds toEncryptionError factory. |
| packages/stack/src/identity/index.ts | Migrates CTS-token failure mapping to toEncryptionError. |
| packages/stack/src/encryption/index.ts | Migrates client-init failure mapping to toEncryptionError. |
| packages/stack/src/encryption/helpers/validation.ts | Updates validation failure results to include a real Error via the factory. |
| packages/stack/src/encryption/operations/encrypt.ts | Migrates encryption failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/decrypt.ts | Migrates decryption failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/encrypt-query.ts | Migrates encryptQuery failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/encrypt-model.ts | Migrates encryptModel failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/decrypt-model.ts | Migrates decryptModel failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/bulk-encrypt.ts | Migrates bulkEncrypt failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/bulk-decrypt.ts | Migrates bulkDecrypt failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/bulk-encrypt-models.ts | Migrates bulkEncryptModels failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/bulk-decrypt-models.ts | Migrates bulkDecryptModels failure mapping to toEncryptionError. |
| packages/stack/src/encryption/operations/batch-encrypt-query.ts | Migrates batch encryptQuery failure mapping to toEncryptionError. |
| .changeset/byteslice-result-0-5.md | Declares a minor release for the dependency + failure-shape change. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| /** | ||
| * Build an {@link EncryptionError} from a caught value. | ||
| * | ||
| * `@byteslice/result` 0.5 requires a failure to be an `Error` or to carry an |
| const err = error instanceof Error ? error : new Error(getErrorMessage(error)) | ||
| return code === undefined | ||
| ? { type, message: err.message, error: err } | ||
| : { type, message: err.message, code, error: err } | ||
| } |
What
Upgrade
@cipherstash/stack's@byteslice/resultdependency from 0.2.0 → 0.5.0, resolving the breaking change to theResultfailure model. Follows on from #568 (auth 0.41, now merged, already ships 0.5'sResult).Why
@byteslice/result0.5'sFailureOptionno longer accepts a bare{ type: string }shape — a failure must be anErroror carry anerror: Error. Stack'sEncryptionError({ type; message; code? }) satisfied 0.2 but not 0.5, so everyResult<…, EncryptionError>usage broke (78 type errors across 15 files). This unblocks the tracked byteslice alignment and removes a version skew with auth 0.41.How
EncryptionErrorgains a requirederror: Errorholding the originating error.type/message/codeare unchanged, so any code readingresult.failure.type/.message/.codekeeps working — additive for consumers.toEncryptionError(type, error, code?)factory coerces any caught value to a realError(replacing the pre-existing unchecked(error as Error)idiom — a small correctness win) and derives the message.encryption/*+identity/now route through the factory.tsc-driven, mechanical.Verification
tsc --noEmitclean,tsupbuild clean,biome checkclean.validation,wasm-inline-strategy,cjs-require.Client key not configured) — 0 assertion failures, so nothing the refactor touched regressed.Scope
packages/stack.packages/protectis deprecated, so its@byteslice/resultpin is intentionally left untouched.EncryptionError(which flows throughResult) gainederror; theStackErrormember interfaces are unchanged.https://claude.ai/code/session_01RRUEHiYupwGo6eEWTBhRaj