Skip to content

test: close HTTP response bodies in server tests to satisfy lint - #8

Merged
0xProgress merged 2 commits into
mainfrom
copilot/fix-lint-github-actions-job
Sep 17, 2026
Merged

0xProgress merged 2 commits into
mainfrom
copilot/fix-lint-github-actions-job

Conversation

Copilot AI commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Lint was failing in CI (Lint job, check run 105300055160) due to bodyclose findings in server/server_test.go, where several test codepaths could exit via t.Fatalf before body cleanup. This change makes response-body closure explicit at response creation sites so cleanup is guaranteed even on early failures, without changing handler/runtime behavior.

  • Root cause

    • golangci-lint (bodyclose) flagged multiple test cases where resp.Body was not reliably closed.
  • Change

    • Added a small helper:
      func closeBody(t *testing.T, resp *http.Response) {
      	t.Helper()
      	if resp == nil || resp.Body == nil {
      		return
      	}
      	if err := resp.Body.Close(); err != nil {
      		t.Fatalf("close response body: %v", err)
      	}
      }
    • Updated tests to call defer closeBody(t, resp) immediately after each HTTP response is created.
    • Kept drainBody focused on reading only (no implicit close side effect).
  • Scope

    • Test-only change in server/server_test.go (no production code changes).

Related issue

Type

  • New provider
  • Bug fix
  • Documentation
  • Refactor
  • Chore / CI

How I tested it

  • go test ./server
  • go test ./...
  • golangci-lint v2.5.0 run --timeout=5m ./server (same linter version as CI)

Provider PRs only

Skip this section if this is not a provider PR.

  • An open issue existed before I started work (provider: <name> label)
  • Official webhook documentation link:
  • docs/providers/<name>.md written from docs/providers/TEMPLATE.md, every section filled
  • All items on the self-review checklist in CONTRIBUTING.md are checked
  • Provider code imports only standard-library packages
  • Test vectors are real — taken from the provider's official docs, not fabricated
  • Both valid-signature and tampered-body test cases are present

General checklist

  • make check passes locally with no errors
  • PR title follows Conventional Commits (feat:, fix:, docs:, test:, refactor:, chore:, ci:)
  • Nothing is written to stdout except through the JSONL event writer
  • No secrets, tokens, or real webhook payloads are committed

Co-authored-by: 0xProgress <283969857+0xProgress@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job Lint test: close HTTP response bodies in server tests to satisfy lint Sep 17, 2026
Copilot AI requested a review from 0xProgress September 17, 2026 17:06
@0xProgress
0xProgress marked this pull request as ready for review September 17, 2026 17:08
Copilot AI lite review requested due to automatic review settings September 17, 2026 17:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@0xProgress
0xProgress merged commit 755638b into main Sep 17, 2026
9 of 10 checks passed
@0xProgress
0xProgress deleted the copilot/fix-lint-github-actions-job branch September 17, 2026 17:08
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.

3 participants