Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5a029af. Configure here.
| key: ['foo', 'baz'], | ||
| }, | ||
| }), | ||
| ).toRespondWith({ foo: 'bar', baz: 'qux' }); |
There was a problem hiding this comment.
Example test uses unsupported getState keys
Medium Severity
The new example test calls getState with an array key, but snap_getState only accepts a string. That request is rejected as invalid params, so the assertion never receives the expected state object.
Reviewed by Cursor Bugbot for commit 5a029af. Configure here.
| newState = set(newState, currentKey, value[currentKey] ?? null); | ||
| } | ||
|
|
||
| return newState; |
There was a problem hiding this comment.
Multi-key update is not atomic
Medium Severity
set mutates the cached state in place, and the multi-key loop writes each key before the next. If a later key fails, earlier writes stay in the in-memory cache even though the call errors, so later reads can see a partial update.
Reviewed by Cursor Bugbot for commit 5a029af. Configure here.


Description
Updates
snap_setStateto accept an array of keys in thekeyparameter, allowing a Snap to set multiple state values in a single call.Before
After
Behavior
keyis astring[],valueis expected to be an object and as a result those key/value pairs are set in state.Note
Medium Risk
Changes persisted Snap state merging logic and validation on a security-sensitive RPC path; behavior is additive for string keys but new null-default semantics for omitted array keys could surprise callers.
Overview
snap_setStatenow acceptskeyas a string array, so Snaps can update several state paths in one RPC call instead of one key at a time.When
keyis an array,valuemust be an object whose properties map to those keys; keys listed inkeybut missing fromvalueare written asnull. Parameter validation usesStateKeysStruct/selectiveUnion(string vs array), with a dedicated invalid-params error if the value is not an object.SetStateParamsin@metamask/snaps-sdkis updated tokey?: string | string[].Coverage adds unit tests in
setState.test.ts, an integration test in the manage-state example, and the test-snapsSetStateUI (comma-separated keys). Changelogs and Jest coverage thresholds are bumped accordingly.Reviewed by Cursor Bugbot for commit 5a029af. Bugbot is set up for automated code reviews on this repo. Configure here.