Skip to content

Conversation

@guzalv
Copy link
Contributor

@guzalv guzalv commented Dec 29, 2025

Description

This PR fixes a bug in rhel.PackageScanner.Scan where filesystem walk errors from rpm.FindDBs were silently swallowed, causing the function to return ([], nil) instead of propagating errors.

Details

The function used unnamed return parameters with a defer that attempted to modify the error return value, however the code was returning explicit nil.

When rpm.FindDBs() encounters filesystem errors (real example: when zombie processes exist in the system and FindDBs traverses /proc, see ROX-32459), the walk terminates early but the error is lost. This causes scanners to silently skip packages instead of reporting the error.

Solution

Changed the function signature to use named return parameters, matching the pattern in rpm.Scanner.Scan.

Testing

Built Stackrox's roxagent with these changes and verified that it throws an error when the DB cannot be found due to filesystem-related errors, rather than silently skipping it and generating empty reports:

virtualmachines/roxagent/cmd: 2025/12/30 09:16:11.966437 cmd.go:56: Error: Running indexer: creating index report: failed to run package scanner: failed to invoke RHEL scanner: readdirent proc/4703/net: invalid argument

Review on CodeApprove

@guzalv guzalv force-pushed the fix-rhel-packagescanner-error-swallowing branch 3 times, most recently from fe573aa to 0daa140 Compare December 29, 2025 12:09
@guzalv guzalv changed the title rhel: fix error swallowing in PackageScanner rhel: Fix error swallowing in PackageScanner Dec 30, 2025
@guzalv guzalv force-pushed the fix-rhel-packagescanner-error-swallowing branch from a396676 to 78ef7d0 Compare December 30, 2025 14:43
@guzalv guzalv marked this pull request as ready for review December 30, 2025 14:44
@guzalv guzalv requested a review from a team as a code owner December 30, 2025 14:44
@guzalv guzalv requested review from crozzy and removed request for a team December 30, 2025 14:44
Copy link
Contributor Author

guzalv commented Dec 30, 2025

Automated comment from CodeApprove ➜

@crozzy please review this Pull Request

Fix bug where filesystem walk errors from rpm.FindDBs were silently
swallowed. The defer attempted to modify a local 'err' variable but
couldn't affect the returned error value due to unnamed return params.

Changed function signature to use named return parameters matching the
pattern in rpm.Scanner. This allows the defer to modify the returned
error value. Using a bare return statement makes it clear that the
defer will set the final error value.

The bug caused PackageScanner to return ([], nil) when encountering
filesystem errors (e.g., from zombie processes in /proc), instead of
properly propagating the error.

Signed-off-by: Guzman <guz@redhat.com>
@guzalv guzalv force-pushed the fix-rhel-packagescanner-error-swallowing branch from 78ef7d0 to f9b3bf0 Compare December 30, 2025 22:37
Copy link
Contributor

@crozzy crozzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated comment from CodeApprove ➜

Approved on CodeApprove
✔️ Approved

Thanks for this, LGTM


👀 @guzalv it's your turn please take a look

@crozzy
Copy link
Contributor

crozzy commented Jan 2, 2026

/fast-forward

@github-actions github-actions bot merged commit f9b3bf0 into quay:main Jan 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants