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:
idhyt
2026-10-26 15:05:27 +00:00
committed by GitHub
parent 722df28ed1
commit 1401107138
+3 -3
View File
@@ -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)
}
}
}