Conversation
There was a problem hiding this comment.
Pull request overview
Adds new tests to cover connectTimeout defaulting behavior in NewHTTPConnection, motivated by issue #3933 and intended to act as a regression suite.
Changes:
- Adds a new
connect_timeout_test.gofile with 4 tests aroundconnectTimeoutdefaulting and preservation. - Introduces a minimal
httptestserver helper intended to allowNewHTTPConnectionto complete its handshake.
Show a summary per file
| File | Description |
|---|---|
internal/mcp/connect_timeout_test.go |
Adds white-box tests asserting how NewHTTPConnection stores connectTimeout (default/negative/custom) and attempts to guard the default value. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
internal/mcp/connect_timeout_test.go:87
TestDefaultConnectTimeout_Valuecurrently assertsdefaultConnectTimeoutis30*time.Second, butdefaultConnectTimeoutis not defined in this package today. If the intent is to prevent drift from the canonical config value, assert againsttime.Duration(config.DefaultConnectTimeout) * time.Second(importinginternal/config) rather than duplicating30*time.Second, so the test fails when code and config diverge.
// TestDefaultConnectTimeout_Value guards against the constant value drifting
// away from config.DefaultConnectTimeout (30 s) unintentionally.
func TestDefaultConnectTimeout_Value(t *testing.T) {
assert.Equal(t, 30*time.Second, defaultConnectTimeout,
"defaultConnectTimeout must remain 30 s to stay in sync with config.DefaultConnectTimeout")
}
- Files reviewed: 1/1 changed files
- Comments generated: 2
| assert.Equal(t, defaultConnectTimeout, conn.connectTimeout, | ||
| "zero connectTimeout should be replaced with defaultConnectTimeout") |
There was a problem hiding this comment.
These assertions reference defaultConnectTimeout, but there is no defaultConnectTimeout identifier defined anywhere in internal/mcp (the current implementation hard-codes 30 * time.Second in NewHTTPConnection). As written, this file will not compile. Either introduce defaultConnectTimeout in the production code (and use it in NewHTTPConnection), or have the tests derive the expected value from internal/config.DefaultConnectTimeout (e.g., time.Duration(config.DefaultConnectTimeout) * time.Second) / inline the expected duration.
This issue also appears on line 82 of the same file.
Add four tests in package mcp covering the connectTimeout defaulting logic in NewHTTPConnection: - TestNewHTTPConnection_DefaultConnectTimeout_ZeroInput Ensures that connectTimeout=0 falls back to defaultConnectTimeout (30 s). - TestNewHTTPConnection_DefaultConnectTimeout_NegativeInput Ensures that connectTimeout<0 also falls back (guards the <= 0 fix for the bug identified in #3933). - TestNewHTTPConnection_DefaultConnectTimeout_CustomValue Ensures that a positive connectTimeout is stored unchanged. - TestDefaultConnectTimeout_Value Guards the constant value so any drift from config.DefaultConnectTimeout (30 s) causes an immediate, obvious test failure rather than a silent bug. These tests directly exercise the paths fixed in fix(mcp):#3933 and provide regression coverage for future changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
825fc60 to
9b7bfbc
Compare
🤖 This is a Repo Assist automated pull request.
Summary
Adds four white-box tests in
package mcpto cover theconnectTimeoutdefaulting behaviour inNewHTTPConnection.These tests were motivated by the bug in #3933 (inconsistent
== 0guard inreconnectSDKTransport) and serve as regression guards for both fixes.Tests Added
TestNewHTTPConnection_DefaultConnectTimeout_ZeroInputconnectTimeout=0→ stored asdefaultConnectTimeout(30 s)TestNewHTTPConnection_DefaultConnectTimeout_NegativeInputconnectTimeout=-1s→ stored asdefaultConnectTimeout(guards the<= 0fix)TestNewHTTPConnection_DefaultConnectTimeout_CustomValueconnectTimeout=10s→ stored unchangedTestDefaultConnectTimeout_ValuedefaultConnectTimeout == 30*time.Second— prevents silent drift fromconfig.DefaultConnectTimeoutImplementation notes
package mcp(white-box, same as existinghttp_connection_test.go) to allow direct access to the unexportedconn.connectTimeoutfield.newMinimalTestServerhelper constructs the httptest server needed forNewHTTPConnectionto complete its handshake.Test Status
proxy.golang.orgis blocked in this environment, preventinggo testfrom running locally. The tests follow the same pattern as the existinghttp_connection_test.gotests and are written to pass against the companion fix PR (repo-assist/fix-issue-3933-connect-timeout).Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.