fix: G118: Goroutine uses context.Background/TODO (gosec)#6666
Draft
thaJeztah wants to merge 2 commits into
Draft
fix: G118: Goroutine uses context.Background/TODO (gosec)#6666thaJeztah wants to merge 2 commits into
thaJeztah wants to merge 2 commits into
Conversation
thaJeztah
commented
Apr 7, 2026
Member
60f575d to
dbe48a9
Compare
tonistiigi
reviewed
Apr 8, 2026
| defer func() { | ||
| if err != nil { | ||
| l.Discard() | ||
| _ = l.Discard(ctx) |
Member
There was a problem hiding this comment.
defers should not use original context
| func (l *LeaseRef) Discard() error { | ||
| return l.lm.Delete(context.Background(), l.l) | ||
| func (l *LeaseRef) Discard(ctx context.Context) error { | ||
| return l.lm.Delete(context.WithoutCancel(ctx), l.l) |
Member
There was a problem hiding this comment.
This WithoutCancel should not be added in Discard
cache/manager.go:238:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
go link.Release(context.TODO())
^
cache/refs.go:1519:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
go func() {
^
session/testutil/testutil.go:22:3: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
go func() {
^
solver/edge.go:975:4: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
go results[i].Release(context.TODO())
^
util/leaseutil/manager.go:79:2: G118: Goroutine uses context.Background/TODO while request-scoped context is available (gosec)
go l.Discard()
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
client/build_test.go:2363:14: SA1019: proxy.Director has been deprecated since Go 1.26 and an alternative has been available since Go 1.20: Use Rewrite instead. (staticcheck) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
dbe48a9 to
4bbba58
Compare
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.