Skip to content

fix(frontend): Prevent TypeError from null rows in CodeTreeTable subtotal - #4103

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/code-tree-table-null-rows
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/code-tree-table-null-rows

Conversation

@sentry

@sentry sentry Bot commented Aug 28, 2026

Copy link
Copy Markdown

Description

This PR addresses a TypeError: Cannot read properties of null (reading 'lines') occurring in the CodeTreeTable component, specifically within the calculateColumnTotal function.

Problem: The data.reduce operation used to calculate column totals (e.g., for 'lines', 'hits') did not account for null entries within the data array. While react-table can tolerate null rows during rendering, the reducer would attempt to access properties of null, leading to a crash.

Root Cause: The calculateColumnTotal function's reduce callback was missing a null guard. When the data array, which can contain null entries (originating from the GraphQL API response for certain repo tree paths), was processed, row[columnId] would throw an error if row was null.

Solution: A defensive null guard (if (!row) return sum) has been added at the beginning of the reduce callback in calculateColumnTotal. This ensures that null rows are gracefully skipped, contributing 0 to the sum, and preventing the TypeError.

Code Example

// Before
data.reduce((sum, row) => sum + row[columnId], 0);

// After
data.reduce((sum, row) => {
  if (!row) return sum; // Null guard
  return sum + row[columnId];
}, 0);

Notable Changes

Added a defensive null guard (if (!row) return sum) to the reduce callback within the calculateColumnTotal function in the CodeTreeTable component to prevent TypeError when processing null data entries.

Screenshots

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness 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 Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.

Fixes GAZEBO-16B7

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

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Bundle Report

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

Detailed changes
Bundle name Size Change
gazebo-production-system 5.82MB 15 bytes (0.0%) ⬆️
gazebo-production-esm 5.89MB 15 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 15 bytes 84.73kB 0.02%

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

  • ./src/pages/RepoPage/CoverageTab/OverviewTab/subroute/FileExplorer/CodeTreeTable/CodeTreeTable.tsx → Total Size: 7.55kB
view changes for bundle: gazebo-production-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index.*.js 15 bytes 89.98kB 0.02%

Files in assets/index.*.js:

  • ./src/pages/RepoPage/CoverageTab/OverviewTab/subroute/FileExplorer/CodeTreeTable/CodeTreeTable.tsx → Total Size: 7.55kB

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.77%. Comparing base (b8fbfc0) to head (141c25e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4103   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files         823      823           
  Lines       15147    15148    +1     
  Branches     4387     4380    -7     
=======================================
+ Hits        14961    14962    +1     
  Misses        179      179           
  Partials        7        7           
Files with missing lines Coverage Δ
...route/FileExplorer/CodeTreeTable/CodeTreeTable.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.72% <ø> (ø)
Pages 98.43% <100.00%> (+<0.01%) ⬆️
Services 99.32% <ø> (ø)
Shared 98.94% <ø> (ø)
UI 99.02% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8fbfc0...141c25e. Read the comment docs.

@codecov-public-qa

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.77%. Comparing base (b8fbfc0) to head (141c25e).

✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main    #4103   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files         823      823           
  Lines       15147    15148    +1     
  Branches     4379     4380    +1     
=======================================
+ Hits        14961    14962    +1     
  Misses        179      179           
  Partials        7        7           
Files with missing lines Coverage Δ
...route/FileExplorer/CodeTreeTable/CodeTreeTable.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.72% <ø> (ø)
Pages 98.43% <100.00%> (+<0.01%) ⬆️
Services 99.32% <ø> (ø)
Shared 98.94% <ø> (ø)
UI 99.02% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8fbfc0...141c25e. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codecov-notifications

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

@@           Coverage Diff           @@
##             main    #4103   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files         823      823           
  Lines       15147    15148    +1     
  Branches     4387     4388    +1     
=======================================
+ Hits        14961    14962    +1     
  Misses        179      179           
  Partials        7        7           
Files with missing lines Coverage Δ
...route/FileExplorer/CodeTreeTable/CodeTreeTable.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.72% <ø> (ø)
Pages 98.43% <100.00%> (+<0.01%) ⬆️
Services 99.32% <ø> (ø)
Shared 98.94% <ø> (ø)
UI 99.02% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8fbfc0...141c25e. Read the comment docs.

@codecov-qa

codecov-qa Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.77%. Comparing base (b8fbfc0) to head (141c25e).

@@           Coverage Diff           @@
##             main    #4103   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files         823      823           
  Lines       15147    15148    +1     
  Branches     4387     4388    +1     
=======================================
+ Hits        14961    14962    +1     
  Misses        179      179           
  Partials        7        7           
Files with missing lines Coverage Δ
...route/FileExplorer/CodeTreeTable/CodeTreeTable.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.72% <ø> (ø)
Pages 98.43% <100.00%> (+<0.01%) ⬆️
Services 99.32% <ø> (ø)
Shared 98.94% <ø> (ø)
UI 99.02% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8fbfc0...141c25e. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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