Skip to content

Fix panic in FilterModules when processing modules with no Go source files#733

Open
krishardy wants to merge 1 commit into
CycloneDX:mainfrom
krishardy:main
Open

Fix panic in FilterModules when processing modules with no Go source files#733
krishardy wants to merge 1 commit into
CycloneDX:mainfrom
krishardy:main

Conversation

@krishardy

@krishardy krishardy commented Mar 10, 2026

Copy link
Copy Markdown

Issue: #734

Always include the main module (mod.Main == true) without subjecting it to go mod why filtering, which would otherwise exclude it when no packages are imported

Add bounds check in generator.Generate to return an error instead of panicking when the module list is empty

Fix stdlib version redaction in test helper to percent-encode : as %3A when searching within PackageURL (which URL-encodes the version), while keeping literal matching for BOMRef

Expand TestParseModWhy into subtests; add NoDirectDependencies case where all modules are reported as unneeded by go mod why

…e files: always include the main module (mod.Main == true) without subjecting it to go mod why filtering, which would otherwise exclude it when no packages are imported

- Add bounds check in generator.Generate to return an error instead of panicking when the module list is empty
- Fix stdlib version redaction in test helper to percent-encode : as %3A when searching within PackageURL (which URL-encodes the version), while keeping literal matching for BOMRef
- Expand TestParseModWhy into subtests; add NoDirectDependencies case where all modules are reported as unneeded by go mod why
@krishardy
krishardy marked this pull request as ready for review March 10, 2026 03:53
@krishardy
krishardy requested a review from a team as a code owner March 10, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant