Skip to content

Fix broken dependency list aggregation

What does this MR do and why?

7bd1e41b added an ignore_column statement onto Sbom::Occurrences which causes ActiveRecord to use select(*model.column_names) as the default select statement instead of SELECT *. Since the occurrence_count and project_count columns are defined inline using an AS statement, we were dependent on SELECT * to have these columns appear in the result set. This introduced a regression which caused the dependency list to not correctly group projects and locations. To fix the regression, we explicitly select these columns in order to ensure that they appear in the result set while ignored columns do not. The bug is further explained in this comment.

Fixes: #434134 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2023-12-06_at_3.55.51_PM Screenshot_2023-12-06_at_3.53.47_PM

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Have a group with dependencies in the dependency list.

  2. Start the rails console

  3. Run this code:

    Group.find_by_full_path('<my group>').sbom_occurrences.first.project_count

    This should return a number instead of raising NoMethodError.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Brian Williams

Merge request reports

Loading