Skip to content

Refactor HTTP client transport cloning in MCP transport builders - #9132

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-http-client-clone
Jul 11, 2026
Merged

Refactor HTTP client transport cloning in MCP transport builders#9132
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-http-client-clone

Conversation

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Renames the shared HTTP client cloning helper in internal/mcp/http_transport_client.go and adds focused unit coverage.

  • Rename: cloneHTTPClientWithTransportcloneClientWithTransport (drops the redundant HTTP infix; both call sites updated)
  • Tests added:
    • TestCloneClientWithTransport — verifies shallow-clone behavior and transport replacement
    • TestResolveBaseTransport — verifies nil-transport fallback to http.DefaultTransport

No functional changes; both buildHTTPClientWithHeaders and buildHTTPClientWithOIDC already shared the same helper before this PR.

Copilot AI changed the title [WIP] Refactor duplicate HTTP client transport cloning code Refactor HTTP client transport cloning in MCP transport builders Jul 11, 2026
Copilot finished work on behalf of lpcox July 11, 2026 18:54
Copilot AI requested a review from lpcox July 11, 2026 18:54
@lpcox
lpcox marked this pull request as ready for review July 11, 2026 18:55
Copilot AI review requested due to automatic review settings July 11, 2026 18:55

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.

Pull request overview

Renames the existing shared HTTP client cloning helper and adds focused unit coverage.

Changes:

  • Renames cloneHTTPClientWithTransport.
  • Tests cloning and default transport resolution.
  • No functional transport-building change.
Show a summary per file
File Description
internal/mcp/http_transport_client.go Renames the shared cloning helper.
internal/mcp/http_transport_test.go Adds helper unit tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment on lines +49 to +51
// cloneClientWithTransport returns a shallow copy of baseClient with the given transport.
// Callers constructing a wrapper transport should use resolveBaseTransport to obtain its base.
func cloneHTTPClientWithTransport(baseClient *http.Client, newTransport http.RoundTripper) *http.Client {
func cloneClientWithTransport(baseClient *http.Client, newTransport http.RoundTripper) *http.Client {
@lpcox

lpcox commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Updated the PR description to accurately reflect the scope of the change: it's a rename of the existing shared helper plus new unit tests, with no duplication removed (both builders already shared cloneHTTPClientWithTransport before this PR).

Copilot finished work on behalf of lpcox July 11, 2026 19:20
@lpcox
lpcox merged commit bbef3fa into main Jul 11, 2026
47 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-http-client-clone branch July 11, 2026 20:02
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.

[duplicate-code] Duplicate Code Pattern: HTTP Client Transport Clone in internal/mcp/http_transport_client.go

3 participants