Skip to content

fix(stats): Guard responseJSON access on stats error panel - #128336

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/stats-responsejson-guard
Open

sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/stats-responsejson-guard

Conversation

@sentry

@sentry sentry Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

When the project stats query fails without a JSON body (e.g. on network-level failures), RequestError.responseJSON is undefined. In usageTable.tsx, getErrorMessage was accessing errorMessage.projectStats.responseJSON.detail directly, which threw a TypeError: Cannot read properties of undefined (reading 'detail') and caused the stats page's error boundary to catch the unhandled render crash instead of displaying the fallback error panel.

Changes:

  • Safely access errors?.projectStats?.responseJSON?.detail in getErrorMessage using optional chaining.
  • Tighten the typing on UsageTable's errors prop from Record<string, Error> to Record<string, RequestError> and drop the any on getErrorMessage's parameter, allowing TypeScript to catch unguarded accesses.
  • Add a regression test in static/app/views/organizationStats/index.spec.tsx verifying that a failed stats request without a response body renders the error panel safely.

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 JAVASCRIPT-3FX1

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

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

@sentry
sentry Bot requested a review from a team as a code owner October 21, 2026 10:48
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 21, 2026
@getsantry

getsantry Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry Bot added the Stale label Nov 12, 2026

This branch was successfully deployed

1 active deployment
Preview — 71ca8901 Deployed Oct 21, 2026 by vercel[bot]
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 Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants