Skip to content

fix: Preserve data.cause when deserializing#7838

Merged
FrederikBolding merged 3 commits into
mainfrom
fb/preserve-data-cause-when-deserializing
Feb 4, 2026
Merged

fix: Preserve data.cause when deserializing#7838
FrederikBolding merged 3 commits into
mainfrom
fb/preserve-data-cause-when-deserializing

Conversation

@FrederikBolding
Copy link
Copy Markdown
Member

@FrederikBolding FrederikBolding commented Feb 4, 2026

Explanation

Preserve data.cause if it exists when deserializing errors from legacy middlewares.

This bug prevents us from using JsonRpcEngineV2 for Snaps.


Note

Low Risk
Low risk: small, localized change to error deserialization that only affects how data.cause is merged; covered by a new unit test and a minor test expectation adjustment downstream.

Overview
Fixes deserializeError/compatibility deserialization so that when data is an object, an existing data.cause is preserved (and not overwritten by an undefined top-level cause).

Adds a regression test for wrapped Snap-style errors and updates a network-controller test matcher to tolerate additional error data fields. Also documents the fix in the @metamask/json-rpc-engine changelog.

Written by Cursor Bugbot for commit 83d74a5. This will update automatically on new commits. Configure here.

@FrederikBolding FrederikBolding requested review from a team as code owners February 4, 2026 14:40
GuillaumeRx
GuillaumeRx previously approved these changes Feb 4, 2026
Mrtenz
Mrtenz previously approved these changes Feb 4, 2026
mcmire
mcmire previously approved these changes Feb 4, 2026
Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@FrederikBolding FrederikBolding dismissed stale reviews from mcmire, Mrtenz, and GuillaumeRx via 0b69ef4 February 4, 2026 14:46
@FrederikBolding FrederikBolding requested a review from a team as a code owner February 4, 2026 14:56
code: errorCodes.rpc.resourceUnavailable,
message: 'RPC endpoint not found or unavailable.',
data: {
data: expect.objectContaining({
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cause can now be null in these tests where previously it was undefined.

@mcmire Are you good with this workaround?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that's fine!

Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@FrederikBolding FrederikBolding added this pull request to the merge queue Feb 4, 2026
Merged via the queue into main with commit 4c7bf68 Feb 4, 2026
595 of 597 checks passed
@FrederikBolding FrederikBolding deleted the fb/preserve-data-cause-when-deserializing branch February 4, 2026 18:31
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.

4 participants