Skip to content

Close HTTP response bodies to fix bodyclose lint#566

Merged
JamieMagee merged 1 commit intomainfrom
jamiemagee/fix-bodyclose-lint
Feb 10, 2026
Merged

Close HTTP response bodies to fix bodyclose lint#566
JamieMagee merged 1 commit intomainfrom
jamiemagee/fix-bodyclose-lint

Conversation

@JamieMagee
Copy link
Member

golangci-lint's bodyclose checker flagged two unclosed HTTP response bodies:

  • cmd/dependabot/internal/cmd/update_test.gohttp.Post response was discarded (_, err := ...). Now we capture the response and call resp.Body.Close() before returning from the retry loop.
  • internal/infra/run.go (checkCredAccess) — the response from the GitHub API token-scope check was never closed. Added defer resp.Body.Close() after the error check.

Two spots were missing resp.Body.Close() calls:

- update_test.go: the http.Post response was discarded. Now we
  capture it and close the body before returning.
- run.go (checkCredAccess): the response from the GitHub API
  token-scope check was never closed. Added a defer.
@JamieMagee JamieMagee requested review from a team as code owners February 10, 2026 00:00
@JamieMagee JamieMagee enabled auto-merge February 10, 2026 00:01
@JamieMagee JamieMagee added this pull request to the merge queue Feb 10, 2026
Merged via the queue into main with commit 9b7e4fb Feb 10, 2026
89 checks passed
@JamieMagee JamieMagee deleted the jamiemagee/fix-bodyclose-lint branch February 10, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants