Skip to content

fix(plugins): Guard against non-array data in pluginsStore.onFetchAllSuccess#115994

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/jest-26zp-plugins-store-map-error
Draft

fix(plugins): Guard against non-array data in pluginsStore.onFetchAllSuccess#115994
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/jest-26zp-plugins-store-map-error

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented May 21, 2026

This PR addresses a TypeError: data.map is not a function occurring in pluginsStore.tsx within CI/PR environments.

Problem:
The onFetchAllSuccess method in pluginsStore was attempting to call .map() on its data argument. However, due to an incomplete refactoring, data was sometimes a Map object (or another non-array type) instead of the expected array, leading to the TypeError.

Solution:

  1. Input Guard: Modified onFetchAllSuccess to include a guard (Array.isArray(data) ? data : []) to ensure data is always an array before .map() is called. This prevents the TypeError when a non-array is passed.
  2. State Serialization: Updated triggerState() and getState() methods to serialize the internal this.plugins (which is a Map<string, Plugin>) into a Plugin[] array ([...this.plugins.values()]) when emitting the store's state. This ensures that external consumers, including tests, receive the expected array format for plugins.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes JEST-26ZP

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.61%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants