[capycli] Fix find_bom_item silently failing when filter has no Version key#224
[capycli] Fix find_bom_item silently failing when filter has no Version key#224prajakta128 wants to merge 2 commits into
Conversation
|
Thank you again, @prajakta128 for this finding! While the root cause fix looks good and adding a focused unit test for it is great, I would be even more interested in the user-facing problem you mention with creating duplicates. Would you mind creating a 2nd test case using the sut.run() or sut.filter_bom() patter from the other TCs in the file to also verify that no such duplicates are created? I would really be interested in understanding the code flow here better. |
|
@gernot-h Thanks for the detailed explanation! I've added a second test It creates a filter entry with only "Name": "colorama" (no Version) and
This confirms the fix correctly updates the existing component instead of |
Problem
find_bom_itemsilently returnsNonewhen a filter entry has aNamebut no
Versionkey. This is a valid and common use case — a user wantsto find a component by name regardless of its version.
The bug causes
addmode updates to silently fail: instead of updatingthe existing component, a duplicate is added with no version.
Root Cause
The method uses
filterentry.get("Version", "x")as a fallback, so whenVersionis missing, it compares"x"against the real version string,which never matches:
Fix
Changed the version check to only enforce version matching when the
Versionkey is actually present in the filter entry:Test Added
Added
test_find_bom_item_name_onlyintests/test_bom_filter.pycovering the case where a filter entry has only
Nameand noVersionkey.Impact
Any user writing a filter file with name-only entries (no Version) to
update components would silently get duplicate ghost components in their
SBOM with no error message shown.