Skip to content

fix: Ensure component and flag data is always an array before mapping - #164

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/component-flag-map-error
Open

fix: Ensure component and flag data is always an array before mapping#164
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/component-flag-map-error

Conversation

@sentry

@sentry sentry Bot commented Aug 27, 2026

Copy link
Copy Markdown

This PR resolves a TypeError: .map is not a function occurring in getComponents and getFlags when processing cached API responses.

Root Cause:
API error responses (e.g., 404, 403, 429) from the /components and /flags endpoints return a JSON object (e.g., {detail: "..."}) instead of an array. Previously, listComponents and listFlags in src/service.ts would unconditionally cache these error objects. On subsequent requests, the cached object was returned with ok: true, leading getComponents or getFlags to attempt calling .map() on a non-array object.

Changes Made:

  1. src/service.ts: Modified listComponents and listFlags to only call setCached if response.ok is true. This prevents API error response objects from being stored in the cache.
  2. src/content/github/common/fetchers.ts: Added Array.isArray() checks in getComponents and getFlags before attempting to call .map(). This provides a defensive guard, ensuring that .map() is only ever called on actual arrays, protecting against any existing stale bad cache entries or future regressions.

Fixes BROWSER-EXTENSION-DW

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 144 bytes (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
codecov-browser-extension-array-push 660.61kB 144 bytes (0.02%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: codecov-browser-extension-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
background.js 101 bytes 207.76kB 0.05%
githubFile.js 43 bytes 11.51kB 0.38%

Files in githubFile.js:

  • ./src/content/github/common/fetchers.ts → Total Size: 2.48kB

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.

0 participants