Skip to content

fix(sigretests.filterOptionalJobs): consider http status#107

Merged
dhiller merged 4 commits intomainfrom
fix-invalid-char-on-getJobsForLatestCommit
Feb 19, 2026
Merged

fix(sigretests.filterOptionalJobs): consider http status#107
dhiller merged 4 commits intomainfrom
fix-invalid-char-on-getJobsForLatestCommit

Conversation

@dhiller
Copy link
Contributor

@dhiller dhiller commented Feb 18, 2026

What this PR does / why we need it:

Adds a missing http status check when filtering for optional lanes.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #106

Special notes for your reviewer:

/cc @dollierp

Signed-off-by: Daniel Hiller <dhiller@redhat.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XL labels Feb 18, 2026
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In filterOptionalJobs, you access prowJobJSON.StatusCode before checking the err from http.Get; swap the order so you return on error before dereferencing a potentially nil response.
  • When skipping non-200 responses in filterOptionalJobs, make sure to close prowJobJSON.Body before continue, and consider replacing the per-iteration defer prowJobJSON.Body.Close() with an explicit Close() to avoid accumulating open connections in the loop.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `filterOptionalJobs`, you access `prowJobJSON.StatusCode` before checking the `err` from `http.Get`; swap the order so you return on error before dereferencing a potentially nil response.
- When skipping non-200 responses in `filterOptionalJobs`, make sure to close `prowJobJSON.Body` before `continue`, and consider replacing the per-iteration `defer prowJobJSON.Body.Close()` with an explicit `Close()` to avoid accumulating open connections in the loop.

## Individual Comments

### Comment 1
<location> `pkg/sigretests/main.go:169-170` </location>
<code_context>
 	var filteredJobs []job
 	for _, j := range unfilteredJobs {
 		prowJobJSON, err := http.Get(fmt.Sprintf(prowJobJSONURL, org, repo, prNumber, j.jobName, j.buildNumber))
+		if prowJobJSON.StatusCode != 200 {
+			continue
+		}
</code_context>

<issue_to_address>
**issue (bug_risk):** StatusCode is accessed before checking `err`, which can panic if `http.Get` fails.

If `http.Get` returns an error, `prowJobJSON` will be nil and accessing `prowJobJSON.StatusCode` will panic. You should check `err` before using the response, then check `StatusCode`, e.g.:

```go
prowJobJSON, err := http.Get(fmt.Sprintf(prowJobJSONURL, org, repo, prNumber, j.jobName, j.buildNumber))
if err != nil {
	return nil, err
}
if prowJobJSON.StatusCode != http.StatusOK {
	prowJobJSON.Body.Close()
	continue
}
defer prowJobJSON.Body.Close()
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +169 to +170
prowJobJSON, err := http.Get(fmt.Sprintf(prowJobJSONURL, org, repo, prNumber, j.jobName, j.buildNumber))
if prowJobJSON.StatusCode != 200 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): StatusCode is accessed before checking err, which can panic if http.Get fails.

If http.Get returns an error, prowJobJSON will be nil and accessing prowJobJSON.StatusCode will panic. You should check err before using the response, then check StatusCode, e.g.:

prowJobJSON, err := http.Get(fmt.Sprintf(prowJobJSONURL, org, repo, prNumber, j.jobName, j.buildNumber))
if err != nil {
	return nil, err
}
if prowJobJSON.StatusCode != http.StatusOK {
	prowJobJSON.Body.Close()
	continue
}
defer prowJobJSON.Body.Close()

Signed-off-by: Daniel Hiller <dhiller@redhat.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
}

defer prowJobJSON.Body.Close()
if prowJobJSON.StatusCode != 200 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/200/http.StatusOK/

@dhiller dhiller requested a review from dollierp February 19, 2026 09:30
@dhiller dhiller merged commit 0d3594a into main Feb 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

badges-update not working any more

3 participants