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

silentred/bmw: worker/resource/request.go; 22 LoC

Open
#13,390 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 [silentred/bmw](https://www.github.com/silentred/bmw) at [worker/resource/request.go](https://github.com/silentred/bmw/blob/146c1f4f929c402f88ee2fb3fa53607f39f09778/worker/resource/request.go#L130-L151)

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.

> reference to item was used in a composite literal at line 149

[Click here to see the code in its original context.](https://github.com/silentred/bmw/blob/146c1f4f929c402f88ee2fb3fa53607f39f09778/worker/resource/request.go#L130-L151)

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

```go
for _, item := range req.Requests {
err = item.makeJobs()
if err != nil {
glog.Error(err)
return err
}

result, err := item.doJobs()
if err != nil {
glog.Error(err)
if err == uploadErr {
return bmw.RetryError
}
}

// save result
store(item.Key, result)

// callback
callback := CallbackBody{&item, result}
batchCallback = append(batchCallback, callback)
}

```

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: 146c1f4f929c402f88ee2fb3fa53607f39f09778

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at worker/resource/request.go lines 130-151 and inspect how the range-loop item is used when constructing CallbackBody. Determine whether the analyzer's reference warning causes incorrect callback behavior, then classify the finding as Bug, Mitigated, or Desirable Behavior; completion requires a justified classification and any relevant verification from the repository.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.