mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
fix(go-module-cataloger): use correct error variable in package load loop (#4983)
In the loop over `rootPkgs`, the error appended to `unknownErr` was incorrectly using the outer `err` (from `packages.Load`) instead of the individual package error `e`. This could cause: - nil or stale error values to be recorded when package-specific errors existed. - Loss of detailed per-package error information in the final error report. Changed `unknown.Append(..., err)` to `unknown.Append(..., e)` to properly capture each package's load error. Signed-off-by: idhyt <idhyt3r@gmail.com>
This commit is contained in:
@@ -137,9 +137,9 @@ func (c *goModCataloger) loadPackages(modDir string, loc file.Location) (pkgs ma
|
||||
for _, p := range rootPkgs {
|
||||
if len(p.Errors) > 0 {
|
||||
// Log errors but continue processing
|
||||
for _, e := range p.Errors {
|
||||
log.Debugf("package load error for %s: %v", p.PkgPath, e)
|
||||
unknownErr = unknown.Append(unknownErr, loc, err)
|
||||
for _, pe := range p.Errors {
|
||||
log.Debugf("package load error for %s: %v", p.PkgPath, pe)
|
||||
unknownErr = unknown.Append(unknownErr, loc, pe)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user