Skip to content

fix: close HTTP response bodies in linear client#52

Merged
russellhaering merged 2 commits into
mainfrom
russell_h/fix_bodyclose_lint
May 15, 2026
Merged

fix: close HTTP response bodies in linear client#52
russellhaering merged 2 commits into
mainfrom
russell_h/fix_bodyclose_lint

Conversation

@russellhaering
Copy link
Copy Markdown
Contributor

Summary

  • Removes *http.Response from the return signatures of the Linear GraphQL helpers (GetUsers, GetTeams, GetProjects, GetOrganization, GetTeam, GetProject, Authorize, GetTeamMemberships, ListTeamWorkflowStates, ListIssueFields, ListIssuesByIDs, GetIssueLabel, CreateIssueLabel). Each helper now defers closeResponse(resp) internally — none of the connector callsites used the response object anyway.
  • Eliminates 14 pre-existing bodyclose lint failures across the connector package. golangci-lint run is now 0 issues.

Test plan

  • go test ./... passes.
  • golangci-lint run --timeout=10m ./... reports 0 issues.
  • Confirm sync still works end-to-end against a live Linear workspace.

Each GraphQL helper that returned *http.Response forced its callers to close
the body; none did. Drop the *http.Response return value and have each helper
close its body internally via a shared closeResponse helper.

Eliminates 14 bodyclose lint failures across the connector package without
changing public connector behavior.
@russellhaering russellhaering requested a review from a team May 15, 2026 21:36
Comment thread pkg/linear/client.go
func closeResponse(resp *http.Response) {
if resp != nil && resp.Body != nil {
_ = resp.Body.Close()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Several other methods in this file (AddMemberToTeam, CreateOrganizationInvite, SuspendUser, RemoveTeamMembership, CreateIssue, BulkCreateIssues, GetIssue) still use defer resp.Body.Close() after the error check. If doRequest ever returns both a non-nil response and an error, those bodies will leak. Consider applying the same closeResponse pattern here for consistency.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

Connector PR Review: fix: close HTTP response bodies in linear client

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Review mode: incremental since c7ac98a
View review run

Review Summary

The new commit applies defer closeResponse(resp) to the 7 remaining methods (AddMemberToTeam, CreateOrganizationInvite, SuspendUser, RemoveTeamMembership, CreateIssue, BulkCreateIssues, GetIssue) that were flagged in the previous review suggestion. The changes are mechanical and consistent with the pattern established in the first commit. The previous suggestion is now fully addressed; no new issues found.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

No blocking issues found.

The mutation helpers were deferring Body.Close after the err check, so when
doRequest returned a non-nil response together with an err (notably the
400/429 rate-limit path), the body leaked. Move defer closeResponse above
the err check across AddMemberToTeam, RemoveTeamMembership,
CreateOrganizationInvite, SuspendUser, CreateIssue, BulkCreateIssues, and
GetIssue for consistency with the read helpers.
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

No blocking issues found.

Copy link
Copy Markdown

@madison-c-evans madison-c-evans left a comment

Choose a reason for hiding this comment

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

lgtm

@madison-c-evans madison-c-evans self-requested a review May 15, 2026 22:04
Copy link
Copy Markdown

@madison-c-evans madison-c-evans left a comment

Choose a reason for hiding this comment

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

LGTM. Nice catch — this is actually a real bug fix on top of the lint cleanup: doRequest returns a non-nil resp along with a non-nil err on Linear's rate-limit path (the 400→429 rewrite at client.go:1075-1080), so under the old defer resp.Body.Close()-after-error-check pattern, bodies leaked on every 429. Moving the defer (via the nil-safe closeResponse helper) before the error check fixes that.

Verified locally: go build, go vet, go test ./... all clean. Every *http.Response removed from the public signatures was already being discarded with _ at every callsite, so the API simplification is risk-free.

@russellhaering russellhaering merged commit 2b664a8 into main May 15, 2026
10 checks passed
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