-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Go: Improve package-not-found diagnostic
#21213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves the go/autobuilder/package-not-found diagnostic message to make it clearer and more helpful for users. The changes address user confusion about whether CodeQL analysis is working and provide environment-specific guidance for setting up access to private registries.
Changes:
- Added new utility functions (
IsActionsWorkflow()andIsDynamicActionsWorkflow()) to detect the execution environment - Updated the diagnostic message to emphasize that CodeQL can analyze code without missing packages before discussing limitations
- Implemented environment-specific guidance for configuring private registry access (different messages for dynamic workflows, custom Actions workflows, and other environments)
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| go/extractor/util/util.go | Added two new helper functions to detect GitHub Actions execution context |
| go/extractor/diagnostics/diagnostics.go | Refactored diagnostic message generation with environment-aware guidance for private registry access |
| go/extractor/cli/go-autobuilder/go-autobuilder.go | Refactored to use new IsActionsWorkflow() utility function instead of inline environment variable check |
| go/extractor/diagnostics/BUILD.bazel | Added dependency on util package (auto-generated by gazelle) |
| go/ql/integration-tests/diagnostics/package-not-found-without-go-mod/test.py | Updated test to set GITHUB_ACTIONS environment variable for consistent test output |
| go/ql/integration-tests/diagnostics/package-not-found-without-go-mod/diagnostics.expected | Updated expected diagnostic message to match new format |
| go/ql/integration-tests/diagnostics/package-not-found-with-go-mod/test.py | Updated test to set GITHUB_ACTIONS environment variable for consistent test output |
| go/ql/integration-tests/diagnostics/package-not-found-with-go-mod/diagnostics.expected | Updated expected diagnostic message to match new format |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7e91ac5 to
f837d90
Compare
This PR improves the
go/autobuilder/package-not-founddiagnostic based on experiences with the current version of it:severityWarning, users sometimes interpret it as an error and incorrectly assume that the Go analysis is not working at all.To address these points, I have made the following changes:
dynamicworkflows, the user is shown a link to the private registry docs. For other Actions workflows, they are told to add a step to configure access. For other environments, they are told to ensuregohas access.Since the diagnostic message now depends on the environment, I have updated the two affected integration tests to always pretend to run in an Actions environment.