Skip to content

fix: Prevent cascading 'Not Found Error' Sentry events on commit page#3984

Draft
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/commit-page-not-found-sentry
Draft

fix: Prevent cascading 'Not Found Error' Sentry events on commit page#3984
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/commit-page-not-found-sentry

Conversation

@sentry

@sentry sentry Bot commented May 28, 2026

Copy link
Copy Markdown

Description

This PR addresses GAZEBO-17YQ, where navigating to a commit page for a non-existent or inaccessible repository resulted in a cascade of 'Not Found Error' Sentry events.

Problem:
When a user visited a commit detail page (e.g., /:provider/:owner/:repo/commit/:commit) for a repository that did not exist or was not configured with Codecov, multiple data-fetching hooks (useCommitTeam, useCommit, useRepoOverview, etc.) would independently query the GraphQL API. The API would correctly return __typename: 'NotFoundError'. Each of these hooks would then call rejectNetworkError, leading to multiple Sentry events for the same underlying issue.

Root Cause:
The CommitDetailPage component was not rendering the <NotFound /> component early enough. While CommitPageDataQueryOpts correctly identified the NotFoundError, it rejected its promise, causing useSuspenseQueryV5 to throw. This prevented the CommitDetailPage's own NotFound guard from being reached before child components (and their respective data hooks) were mounted and executed, leading to redundant Sentry captures.

Solution:

  1. Modify CommitPageDataQueryOpts: Instead of calling rejectNetworkError when repository.__typename === 'NotFoundError', it now returns a simple { notFound: true } sentinel value. This keeps the query resolved (not thrown) and prevents a Sentry event at this level.
  2. Update CommitDetailPage: An early check if ('notFound' in commitPageData && commitPageData.notFound) has been added. If the sentinel is present, the page immediately renders <NotFound />. This ensures that child components and their data hooks are never mounted when the repository is not found.

Benefits:

  • Significantly reduces Sentry noise by preventing multiple redundant 'Not Found Error' events for a single user action.
  • Ensures a consistent and correct user experience by immediately displaying the <NotFound /> page when a repository is genuinely missing or inaccessible, without unnecessary data fetching attempts by child components.

Code Example

N/A

Notable Changes

  • Modified CommitPageDataQueryOpts to return a sentinel value { notFound: true } instead of rejecting the promise when a repository is not found, preventing premature Sentry events.
  • Updated CommitDetailPage to include an early check for this sentinel value, allowing it to render the <NotFound /> component immediately and prevent child components from mounting and initiating redundant data fetches.
  • Reduced Sentry noise by preventing multiple 'Not Found Error' events for a single underlying issue.
  • Improved user experience by ensuring a consistent and immediate display of the <NotFound /> page for missing or inaccessible repositories.

Screenshots

N/A

Link to Sample Entry

N/A

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. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this 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 GAZEBO-17YQ

@sentry

sentry Bot commented May 28, 2026

Copy link
Copy Markdown
Author

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3787 1 3786 2
View the top 1 failed test(s) by shortest run time
src/pages/CommitDetailPage/queries/CommitPageDataQueryOpts.test.tsx > CommitPageData > when executed > returns NotFoundError __typename > throws an error
Stack Traces | 1.02s run time
AssertionError: expected false to be truthy

Ignored nodes: comments, script, style
<html>
  <head />
  <body>
    <div />
  </body>
</html>

- Expected
+ Received

- true
+ false

 ❯ .../CommitDetailPage/queries/CommitPageDataQueryOpts.test.tsx:231:60
 ❯ runWithExpensiveErrorDiagnosticsDisabled node_modules/@.../dom/dist/config.js:47:12
 ❯ checkCallback node_modules/@.../dom/dist/wait-for.js:124:77
 ❯ Timeout.checkRealTimersCallback node_modules/@.../dom/dist/wait-for.js:118:16

@sentry

sentry Bot commented May 28, 2026

Copy link
Copy Markdown
Author

Bundle Report

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

Detailed changes
Bundle name Size Change
gazebo-production-system 5.87MB 4 bytes (0.0%) ⬆️
gazebo-production-esm 5.96MB 3 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: gazebo-production-system

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-legacy.*.js 4 bytes 115.09kB 0.0%

Files in assets/index-legacy.*.js:

  • ./src/pages/CommitDetailPage/CommitDetailPage.tsx → Total Size: 4.05kB

  • ./src/pages/CommitDetailPage/queries/CommitPageDataQueryOpts.tsx → Total Size: 4.57kB

view changes for bundle: gazebo-production-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index.*.js 3 bytes 126.54kB 0.0%

Files in assets/index.*.js:

  • ./src/pages/CommitDetailPage/CommitDetailPage.tsx → Total Size: 4.03kB

  • ./src/pages/CommitDetailPage/queries/CommitPageDataQueryOpts.tsx → Total Size: 4.57kB

@codecov-releaser

Copy link
Copy Markdown
Collaborator

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
77533e6 Thu, 28 May 2026 03:51:43 GMT Cloud Enterprise

@codecov-public-qa

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3051 1 3050 2
View the top 1 failed test(s) by shortest run time
src/pages/CommitDetailPage/queries/CommitPageDataQueryOpts.test.tsx > CommitPageData > when executed > returns NotFoundError __typename > throws an error
Stack Traces | 1.02s run time
AssertionError: expected false to be truthy

Ignored nodes: comments, script, style
<html>
  <head />
  <body>
    <div />
  </body>
</html>

- Expected
+ Received

- true
+ false

 ❯ .../CommitDetailPage/queries/CommitPageDataQueryOpts.test.tsx:231:60runWithExpensiveErrorDiagnosticsDisabled node_modules/@.../dom/dist/config.js:47:12checkCallback node_modules/@.../dom/dist/wait-for.js:124:77Timeout.checkRealTimersCallback node_modules/@.../dom/dist/wait-for.js:118:16

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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.

1 participant