Repository navigation
Add linter for HTTP clients without timeouts - #78691
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟡 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
nolintsuppression. - 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)
| named, ok := t.(*types.Named) | ||
| return ok && named.Obj().Name() == "Client" && named.Obj().Pkg() != nil && named.Obj().Pkg().Path() == "net/http" |
There was a problem hiding this comment.
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.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
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"
}
|
…imeout-9ba03de39368299c Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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 |
|
🎉 This pull request is included in a new release. Release: |

net/http.Clientliterals without aTimeoutcan leave requests blocked indefinitely. The existinghttpnoctxanalyzer does not detect these literals.httpclientnotimeoutto flagnet/http.Clientcomposite literals missingTimeout. Covers pointer and value literals, ignores unrelated types namedClient, and supportsnolintsuppression.