fix: skip vulnerability scanning for packages that failed to build #299
+31
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes vulnerability scanning crash when a dependency build fails in a parallel goroutine but the main build continues due to the build lock mechanism.
Fixes https://linear.app/ona-team/issue/CLC-2122/scan-vulnerabilities-of-packages-iff-their-build-status-is-successful
Problem
In gitpod-next PR #11869, the build fails with:
Root Cause: Build Lock Race Condition
Leeway builds dependencies in parallel using goroutines. When multiple packages depend on the same package, a build lock prevents duplicate builds. However, this creates a race condition when a build fails:
The Scenario
What Happens
api/go:lib, starts building, build fails, releases lock, returns errornil(success) without buildingapi/go:libisn't in cacheCode Evidence
In
pkg/leeway/build.go:The Fix
Vulnerability scanning now:
pkgstatusmap tracking build outcomesPackageBuiltorPackageDownloadedThis prevents the fatal error in vulnerability scanning while still allowing the build to fail if the dependency error propagates through the main dependency chain.
Changes
pkg/leeway/build.go: Passpkgstatusto vulnerability scanningpkg/leeway/sbom-scan.go: Filter packages by build status before scanningTesting
Related