Skip unneeded query when getting CVE chart - #45813
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
Pull request overview
Removes an unnecessary TrackedCriticalCVEs query from the CVE chart data path since the system currently only collects data for tracked CVEs (making the filter redundant), and adds/updates tests to pin the storage-layer empty-slice contract for when filtering is reintroduced.
Changes:
- Drop the
TrackedCriticalCVEslookup inService.GetChartDatafor thecvemetric, leavingentityIDsas nil (no filter). - Remove the now-obsolete service tests that verified filter propagation, and add a MySQL-layer regression test ensuring a non-nil empty
entityIDsslice yields zero-valued buckets. - Add a changes file entry.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| server/chart/internal/service/service.go | Removes the TrackedCriticalCVEs call so entityIDs stays nil for the CVE metric. |
| server/chart/internal/service/service_test.go | Deletes the two service tests that exercised the removed filter path. |
| server/chart/internal/mysql/data_test.go | Adds a storage-layer regression test for the non-nil empty entityIDs contract. |
| changes/45720-remove-unneeded-query | User-visible changelog entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WalkthroughThis PR removes an unneeded Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
This test isn't strictly related to the removed code, but the test that's being removed in this PR indirectly tested the behavior of "asking the chart to display data for an empty set of entity IDs" which was now completely untested. It's worth adding the regression test for it here since we'll add more filtering soon and it'd be easy to forget.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #45813 +/- ##
==========================================
+ Coverage 66.76% 66.78% +0.02%
==========================================
Files 2747 2748 +1
Lines 219605 219825 +220
Branches 10882 10882
==========================================
+ Hits 146610 146803 +193
- Misses 59741 59756 +15
- Partials 13254 13266 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Cherry-pick of #45813 into the RC branch.
Related issue: Resolves #45720
Details
When requesting CVE chart data, we were making a call to get the set of tracked CVEs to filter the data by. Currently we're only collecting data for the tracked CVEs, so there's no reason to make this call at all.
When we add more filtering options and start collecting more data, we'll need a call like this again, and will likely need to start caching the results. Otherwise it's a multi-second cost per query on large deployments.
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests