fix(accounts-controller): guard undefined scopes in multichain listing - #9877
Open
rajanpanth wants to merge 1 commit into
Open
fix(accounts-controller): guard undefined scopes in multichain listing#9877rajanpanth wants to merge 1 commit into
rajanpanth wants to merge 1 commit into
Conversation
rajanpanth
force-pushed
the
fix/accounts-controller-scopes-guard
branch
from
August 15, 2026 03:49
43bdbf6 to
92323a4
Compare
…ltichainAccounts` `listMultichainAccounts(chainId)` filters accounts with `isScopeEqualToAny(chainId, account.scopes)`, which calls `scopes.some(...)`. `InternalAccount.scopes` is typed as required, but a legacy or partially migrated account can be persisted without it, so `account.scopes` can be `undefined` at runtime and throws a `TypeError`. Guard the filter with `Array.isArray(account.scopes)` before matching. An account without a valid `scopes` array declares no chain and is excluded from chain-filtered results instead of throwing; unfiltered `listMultichainAccounts()` is unchanged.
rajanpanth
force-pushed
the
fix/accounts-controller-scopes-guard
branch
from
September 1, 2026 05:54
92323a4 to
c7261bf
Compare
Author
|
Rebased onto The conflict was only in Since that is a lot of drift, I re-verified the fix rather than assuming it survived:
The change itself is unchanged in substance, an |
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
Adds a guard for undefined
scopeswhen listing multichain accounts in the accounts controller flow.Why
Undefined scope payloads can surface in edge cases and currently trigger avoidable runtime failures.
Note
Low Risk
Small defensive guard in account listing with a regression test; behavior change is only to skip malformed legacy accounts rather than throw.
Overview
listMultichainAccountsno longer crashes when persisted internal accounts are missing ascopesarray (legacy or partial migration). Chain-filtered listing now requiresArray.isArray(account.scopes)before callingisScopeEqualToAny, so those accounts are omitted from scoped results instead of causing aTypeError.A regression test covers mixed state (normal account plus
scopes: undefined), and the package changelog documents the fix (#41962).Reviewed by Cursor Bugbot for commit c7261bf. Bugbot is set up for automated code reviews on this repo. Configure here.