github-vet / github-vet/rangeloop-pointer-findings

netlify/go-client: deploys.go; 24 LoC

Open
#12,427 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [netlify/go-client](https://www.github.com/netlify/go-client) at [deploys.go](https://github.com/netlify/go-client/blob/3f96614ba1bc40077610b7a7994475b172c8df5f/deploys.go#L361-L384)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> range-loop variable sha used in defer or goroutine at line 370

[Click here to see the code in its original context.](https://github.com/netlify/go-client/blob/3f96614ba1bc40077610b7a7994475b172c8df5f/deploys.go#L361-L384)

Click here to show the 24 line(s) of Go which triggered the analyzer.

```go
for path, sha := range files {
if lookup[sha] == true && sharedErr.Empty() {
wg.Add(1)
sem <- 1
go func(path string) {
defer func() {
<-sem
wg.Done()
}()
log.Debugf("Starting to upload %s/%s", path, sha)
if !sharedErr.Empty() {
return
}

b := backoff.NewExponentialBackOff()
b.MaxElapsedTime = 2 * time.Minute
err := backoff.Retry(func() error { return deploy.uploadFile(dir, path, &sharedErr) }, b)
if err != nil {
log.WithError(err).Warnf("Error while uploading file %s: %v", path, err)
sharedErr.Set(err)
}
}(path)
}
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 3f96614ba1bc40077610b7a7994475b172c8df5f

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with deploys.go lines 361-384 in the linked netlify/go-client commit and inspect how the range variable sha is used inside the goroutine. Confirm whether the captured value can be incorrect, then classify the finding as Bug, Mitigated, or Desirable Behavior using the linked project guidance and leave the corresponding reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.