Skip to content

Commit 002cf2b

Browse files
committed
Fix module package source RPM matching bug
Module packages were not appearing in updateinfo.xml due to a bug in the source RPM mapping logic. The issue was that binary and source packages were being grouped into different dictionary keys: - Binary packages: package_name='delve', key='go-toolset:delve:rhel8' - Source packages: package_name='module.delve', key='go-toolset:module.delve:rhel8' Because the keys didn't match, the source RPM lookup failed, causing all packages in the advisory to be filtered out, and the entire advisory to be removed from updateinfo.xml. Fix: Strip the 'module.' prefix from package_name when building dictionary keys, so both binary and source packages map to the same key. This allows the source RPM matching to work correctly. Impact: Fixes 181+ advisories with module packages (go-toolset, rust-toolset, etc.) that were previously missing from updateinfo.
1 parent fe6537b commit 002cf2b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

apollo/server/routes/api_updateinfo.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,32 @@ def build_source_rpm_mapping(packages):
4545
}
4646
"""
4747
# First, create a map of package names to their package objects
48+
# Strip "module." prefix from package_name to ensure binary and source packages
49+
# are grouped together (binary: "delve", source: "module.delve" -> both map to "delve")
4850
pkg_name_map = {}
4951
for pkg in packages:
50-
name = pkg.package_name
52+
# Strip module. prefix for consistent grouping
53+
base_pkg_name = pkg.package_name.removeprefix("module.")
54+
5155
if pkg.module_name:
52-
name = f"{pkg.module_name}:{pkg.package_name}:{pkg.module_stream}"
56+
name = f"{pkg.module_name}:{base_pkg_name}:{pkg.module_stream}"
57+
else:
58+
name = base_pkg_name
59+
5360
if name not in pkg_name_map:
5461
pkg_name_map[name] = []
5562
pkg_name_map[name].append(pkg)
5663

5764
# Build the source RPM mapping
5865
pkg_src_rpm = {}
5966
for top_pkg in packages:
60-
name = top_pkg.package_name
67+
# Use same key format as pkg_name_map
68+
base_pkg_name = top_pkg.package_name.removeprefix("module.")
69+
6170
if top_pkg.module_name:
62-
name = f"{top_pkg.module_name}:{top_pkg.package_name}:{top_pkg.module_stream}"
71+
name = f"{top_pkg.module_name}:{base_pkg_name}:{top_pkg.module_stream}"
72+
else:
73+
name = base_pkg_name
6374

6475
if name not in pkg_src_rpm:
6576
for pkg in pkg_name_map[name]:
@@ -80,6 +91,7 @@ def build_source_rpm_mapping(packages):
8091
if not src_rpm.endswith(".rpm"):
8192
src_rpm += ".rpm"
8293
pkg_src_rpm[name] = src_rpm
94+
logger.debug(f"Found source RPM for {name}: {src_rpm} (pkg.package_name={pkg.package_name}, nvr_name={nvr_name})")
8395
break # Found the source RPM, no need to continue
8496

8597
return pkg_src_rpm

0 commit comments

Comments
 (0)