Skip to content

Add linter for HTTP clients without timeouts - #78691

Merged
pelikhan merged 4 commits into
mainfrom
copilot/httpclientnotimeout-9ba03de39368299c
Nov 17, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/httpclientnotimeout-9ba03de39368299c

Conversation

@gh-aw-bot

@gh-aw-bot gh-aw-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

net/http.Client literals without a Timeout can leave requests blocked indefinitely. The existing httpnoctx analyzer does not detect these literals.

  • Analyzer: Add httpclientnotimeout to flag net/http.Client composite literals missing Timeout. Covers pointer and value literals, ignores unrelated types named Client, and supports nolint suppression.
  • Registration and docs: Register the analyzer, update linter documentation and spec tests, and defer CI enforcement pending an audit.
client := &http.Client{} // flagged
client = &http.Client{Timeout: 10 * time.Second} // not flagged

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@gh-aw-bot gh-aw-bot changed the title [WIP] Add httpclientnotimeout analyzer Add linter for HTTP clients without timeouts Nov 17, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 17, 2026 09:58
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 09:58

Copilot AI left a comment

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.

🟡 Changes recommended

Type aliases bypass the timeout check, leaving timeout-less http.Client literals unreported; both type-inspection helpers need alias resolution and regression fixtures.

1 open issue
What changed in this PR

Adds httpclientnotimeout to gh-aw’s custom Go analyzers, detecting net/http.Client literals that omit Timeout and complementing the existing httpnoctx checks.

Changes:

  • Adds the analyzer with type filtering and nolint suppression.
  • Adds fixtures for pointer/value literals, explicit timeouts, unrelated types, and suppression.
  • Registers and documents the analyzer while deferring CI enforcement pending an audit.
File Description
pkg/​linters/​spec_test.go Includes the analyzer in documentation contract tests.
pkg/​linters/​registry.go Registers the new analyzer.
pkg/​linters/​README.md Documents the rule and package usage.
pkg/​linters/​httpclientnotimeout/​testdata/​src/​httpclientnotimeout/​httpclientnotimeout.go Adds diagnostic and suppression fixtures.
pkg/​linters/​httpclientnotimeout/​httpclientnotimeout.go Implements missing-timeout detection.
pkg/​linters/​httpclientnotimeout/​httpclientnotimeout_test.go Runs analyzer tests against fixtures.
pkg/​linters/​doc.go Updates the analyzer catalog and count.
pkg/​linters/​doc_sync_test.go Records deferred CI enforcement.

Review effort: Balanced (adaptive)

Comment on lines +46 to +47
named, ok := t.(*types.Named)
return ok && named.Obj().Name() == "Client" && named.Obj().Pkg() != nil && named.Obj().Pkg().Path() == "net/http"

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.

Fixed in 78810fa: both helpers resolve aliases with types.Unalias. Regression fixtures cover pointer/value aliases, chained aliases, missing timeouts, keyed/positional explicit timeouts, and unrelated aliases. Analyzer and linter-package tests pass.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator Author

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/linters/httpclientnotimeout/httpclientnotimeout.go:47): address unresolved feedback - Review comment
  3. Fix failing check prefetch (FAILURE): Check run.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "7cf936c54c968566e49627ba251b43f5ceac8f2a",
  "kind": "requested",
  "schema_version": "1",
  "state": "969d0fbed753b13c3c6a9406964aa0440b29addb47e10bedb0153b73ee737714",
  "work": [
    "0a1f33e8c9ed0524be159c5b1152359212705bdf7bb3e357431722c2964a6e0f",
    "23027a7a3ebe972cffc3eabad4a22e44dac70312f0e8b312d61f867187f7f01d"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 17, 2026 10:48
…imeout-9ba03de39368299c

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Published main merge 11d2241 and alias fix 78810fa. Regression tests, build, Go/custom lint, and secret scan passed. All 368 workflows compiled; the final gate failed only on existing drift in /home/runner/work/gh-aw/gh-aw/.github/workflows/agent-performance-analyzer.lock.yml, unchanged from main. CodeQL timed out. The linked prefetch job failed with an installation API rate-limit HTTP 403 while fetching review comments; no source fix applies. No CI retry/dispatch or PR merge was performed.

@pelikhan
pelikhan merged commit 65dc782 into main Nov 17, 2026
67 checks passed
@pelikhan
pelikhan deleted the copilot/httpclientnotimeout-9ba03de39368299c branch November 17, 2026 15:07
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.1

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.

[linter-miner] feat(linters): add httpclientnotimeout analyzer

4 participants