chore: add support for contextcheck#5565
Open
remyleone wants to merge 2 commits into
Open
Conversation
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR introduces golangci-lint’s contextcheck and updates several call sites to use inherited contexts instead of creating new background contexts, aligning context propagation across tasks, Cobra, and HTTP operations.
Changes:
- Enable
contextcheckin.golangci.ymland add an exclusion rule for Cobra-related signatures. - Propagate inherited
context.Contextin tasks logging, MCP server shutdown, Cobra usage/run hooks, and build version checks. - Refactor
getLatestVersionto accept acontext.Contextand extract the HTTP client from it.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/tasks/tasks.go | Use the task’s cancelable context when creating the tasks logger. |
| internal/namespaces/mcp/server/streamable_http.go | Attempt to inherit context for graceful shutdown timeout. |
| core/cobra_utils.go | Remove unused context parameter and always source ctx from cobraCmd.Context(). |
| core/cobra_usage_builder.go | Pass command context into annotation building; extract helper. |
| core/cobra_builder.go | Adjust usage builder callback signature and update cobraRun usage. |
| core/build_info.go | Make version checks context-driven; derive timeout from passed context. |
| core/bootstrap.go | Remove nil-context fallback handling. |
| .golangci.yml | Enable contextcheck and add an exclusion rule targeting Cobra patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
45
to
51
| <-ctx.Done() | ||
|
|
||
| // Graceful shutdown with timeout | ||
| shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
| shutdownCtx, shutdownCancel := context.WithTimeout(ctx, 10*time.Second) | ||
| defer shutdownCancel() | ||
|
|
||
| return server.Shutdown(shutdownCtx) |
| @@ -199,9 +199,6 @@ func Bootstrap(ctx context.Context, config *BootstrapConfig) (exitCode int, resu | |||
| meta.OverrideExec = defaultOverrideExec | |||
| } | |||
|
|
|||
|
|
||
| # cobra API requires func(*cobra.Command) error signature; context extracted from command | ||
| - linters: | ||
| - contextcheck |
Comment on lines
+167
to
+171
| func executeWithCtx( | ||
| ctx context.Context, | ||
| cmd *cobra.Command, | ||
| annotationBuilder func(context.Context), | ||
| ) { |
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.
Community Note
Relates OR Closes #0000
Release note for CHANGELOG: