fix(core): stop leaking backend exception details in RPC errors#231
Open
pranavosu wants to merge 1 commit into
Open
fix(core): stop leaking backend exception details in RPC errors#231pranavosu wants to merge 1 commit into
pranavosu wants to merge 1 commit into
Conversation
…ResponseFromCatch forwarded error.message verbatim and copied error.name for any error whose name wasn't literally 'Error', so raw Postgres/DynamoDB driver exception class names and messages reached clients over the wire. Only ApiError is a deliberate wire-safe shape, so it now passes through verbatim (status, message, BB name, retriable) while every other throw collapses to a generic 500 / 'Internal error'. Callers already log the full error server-side. Aligns the implementation with the D-003 safety net (unhandled errors serialize as generic 500s with no name). Fixes #227
🦋 Changeset detectedLatest commit: 43a1d96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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.
Summary
errorResponseFromCatchinpackages/core/src/rpc.tsforwardederror.messageverbatim and copiederror.nameonto the wire for any error whose name wasn't literallyError. Non-ApiErrorthrows — the common case for driver/SDK failures (Postgres, DynamoDB, etc.) — therefore returned a JSON-RPC error whosemessagewas the raw driver message and whosedata.namewas the raw exception class name. That leaks internal implementation details to any caller and produces unstable, non-actionable error shapes.Fixes #227.
Change
errorResponseFromCatchnow treatsApiErroras the only deliberate, wire-safe error shape:ApiErrorpasses through verbatim: HTTPstatusbecomes the code, plusmessage, the BB-levelname(omitted when it's the defaultApiError), andretriable.500/"Internal error"with nodata— no raw class name, no raw message.The full error is still logged server-side by both callers (
lambda-handler.tsconsole.error,dev-server.ts[rpc-err]log + stack), so debuggability is unchanged.This aligns the implementation with the documented D-003 safety net: "Unhandled errors (plain
Errorwith no custom.name) still serialize as generic 500s with no name."Testing
packages/core/src/rpc.test.tscovering: a simulated driver exception (custom class name + secret-bearing message) collapsing to500/Internal errorwith no leaked strings, plainErrorand non-Errorthrows collapsing likewise, andApiErrorpassing through verbatim withstatus/message/name/retriable(including the default-name omission).npm run buildand therpc.test.jssuite pass (12/12). Biome lint clean on the changed files.Note: the
ApiErrorwire contract is unchanged; only previously-unstable non-ApiErrorshapes change, so this is apatch.