fix: filter phantom package paths from ResolvePackagePaths#190
Merged
em-redhat merged 3 commits intoJul 14, 2026
Merged
Conversation
loader.ResolvePackagePaths did not check pkg.Errors on packages returned by go/packages.Load. Nonexistent patterns produced synthetic packages with populated Errors slices that passed through the filter, returning phantom paths as valid. - Add io.Writer parameter for warning output on skipped packages - Skip packages with load errors, emit per-error warning to stderr - Update all callers (cmd/gaze, goprovider, aireport DI wrapper) - Add TestResolvePackagePaths_InvalidPattern regression test Closes unbound-force#104 Assisted-by: claude-opus Generated with AI assistance (claude-opus)
em-redhat
force-pushed
the
opsx/fix-phantom-package-paths
branch
from
July 7, 2026 11:28
84e3277 to
0456aa5
Compare
trevor-vaughan
requested changes
Jul 8, 2026
Adds TestResolvePackagePaths_MixedValidAndInvalid which verifies that when both valid and invalid patterns are provided, only the valid package path is returned while a warning is emitted for the invalid pattern. Addresses PR review feedback requesting mixed-pattern coverage. Assisted-by: claude-opus Generated with AI assistance (claude-opus)
trevor-vaughan
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #104 --
loader.ResolvePackagePathsdid not checkpkg.Errorsonpackages returned by
go/packages.Load. When a pattern doesn't resolve to areal package,
go/packagesreturns a synthetic*packages.PackagewithPkgPathset to the input pattern andErrorspopulated. The filter onlyrejected empty/duplicate/
_testpaths, so phantom paths were returned as valid.This fix adds
pkg.Errorsfiltering and anio.Writerparameter for warningoutput, following the project's established stderr injection pattern.
How to Test
How to Demo
This is an internal bug fix. The observable change is that
gaze analyze,gaze quality,gaze crap, andgaze reportnow emit warnings to stderrwhen a package pattern fails to resolve, instead of silently passing phantom
paths downstream.
Key Files Changed
internal/loader/loader.go-- Core fix:ResolvePackagePathsgainsio.Writerparam andpkg.Errorsfiltering with nil-safe warning outputinternal/loader/loader_test.go-- NewTestResolvePackagePaths_InvalidPattern+ 3 existing test signature updatescmd/gaze/main.go-- 2 callers updated (runAnalyze,runQuality) to passp.stderrinternal/aireport/runner_steps.go-- 2 callers updated (runQualitySteppassesstderr,runClassifySteppassesnilper D4)internal/crap/contract.go-- 1 caller updated (BuildContractCoverageFuncpassesstderr)openspec/changes/fix-phantom-package-paths/-- Proposal, design, spec, and task artifactsThis PR was generated by /finale (AI-assisted).