Skip to content

fix(bundle_analysis): Eagerly load base report to handle MissingBaseReportError - #2160

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/api-bg6-missing-base-report
Open

fix(bundle_analysis): Eagerly load base report to handle MissingBaseReportError#2160
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/api-bg6-missing-base-report

Conversation

@sentry

@sentry sentry Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This PR addresses issue API-BG6, where MissingBaseReportError was being raised as an internal server error instead of being properly handled and returned as a MissingBaseReport GraphQL union type.

The root cause was that BundleAnalysisComparison.__init__ eagerly loaded self.head_report but not self.base_report. Since base_report is a cached_property, the MissingBaseReportError (triggered when the base report was not found in GCS) was only raised later when resolve_commit_bundle_analysis_compare_with_parent accessed base_report.db_path for cleanup. At this point, the try/except block in load_bundle_analysis_comparison (which is designed to catch this error and return the correct GraphQL type) was no longer active.

The fix involves adding self.base_report = self.comparison.base_report to the BundleAnalysisComparison.__init__ method. This ensures that MissingBaseReportError is triggered during the construction of BundleAnalysisComparison, allowing load_bundle_analysis_comparison to catch it and return the appropriate MissingBaseReport GraphQL type, as intended.

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 API-BG6

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

@thomasrockhu-codecov

thomasrockhu-codecov commented Aug 29, 2026

Copy link
Copy Markdown
Contributor
✨ Harness AI Code Review View in Harness →

Risk: LOW

This PR adds a single line to BundleAnalysisComparison.__init__ that eagerly loads self.base_report, so a MissingBaseReportError is raised during construction (inside load_bundle_analysis_comparison's try/except) rather than later, correctly returning the MissingBaseReport GraphQL type. The change mirrors the existing eager head_report load and the path is already covered by test_loader_raises_missing_base_report.

No issues found above the confidence threshold.

@codecov-notifications

Copy link
Copy Markdown

Codecov Report

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

📢 Thoughts on this report? Let us know!

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

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.63%. Comparing base (17e0f08) to head (6563a7b).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2160   +/-   ##
=======================================
  Coverage   91.63%   91.63%           
=======================================
  Files        1337     1337           
  Lines       53262    53263    +1     
  Branches     1647     1647           
=======================================
+ Hits        48805    48806    +1     
  Misses       4136     4136           
  Partials      321      321           
Flag Coverage Δ
apiunit 93.98% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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