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

bosun-monitor/bosun: cmd/scollector/collectors/cadvisor.go; 12 LoC

Open
#15,110 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 [bosun-monitor/bosun](https://www.github.com/bosun-monitor/bosun) at [cmd/scollector/collectors/cadvisor.go](https://github.com/bosun-monitor/bosun/blob/4ea808ab2ddfcd7dcc135372ea217aa17ef764cc/cmd/scollector/collectors/cadvisor.go#L524-L535)

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 config was used in a composite literal at line 531

[Click here to see the code in its original context.](https://github.com/bosun-monitor/bosun/blob/4ea808ab2ddfcd7dcc135372ea217aa17ef764cc/cmd/scollector/collectors/cadvisor.go#L524-L535)

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

```go
for _, config := range c.Cadvisor {
cClient, err := client.NewClient(config.URL)
if err != nil {
slog.Warningf("Could not start collector for URL [%s] due to err: %v", config.URL, err)
}
collectors = append(collectors, &IntervalCollector{
F: func() (opentsdb.MultiDataPoint, error) {
return c_cadvisor(cClient, &config)
},
name: "cadvisor",
})
}

```

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: 4ea808ab2ddfcd7dcc135372ea217aa17ef764cc

Contributor guide

No contributing guide indexed for this repository

Research direction

Read cmd/scollector/collectors/cadvisor.go at lines 524-535, beginning with the range over c.Cadvisor and the IntervalCollector callback. Trace how c_cadvisor uses the captured config and decide whether the analyzer finding is a real bug, mitigated behavior, or desirable behavior; done means applying the corresponding issue classification.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability-sre
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.