You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two functions in internal/mcp/http_transport_client.go share an identical 6-line core for cloning an http.Client and assigning a new transport. This core could be extracted into a private helper.
Duplication Details
Pattern: http.Client shallow clone + transport assignment
The only difference is the concrete RoundTripper type assigned to clone.Transport.
Impact Analysis
Maintainability: Any change to client cloning behavior (e.g., copying additional fields, adding timeout overrides) must be applied to both functions
Bug Risk: Low but present — inconsistent fixes if the nil-guard logic changes
Code Bloat: Minor (~6 lines), but a clear extraction opportunity
Refactoring Recommendations
Extract cloneClientWithTransport helper:
// cloneClientWithTransport returns a shallow clone of baseClient// with Transport replaced by newTransport.funccloneClientWithTransport(baseClient*http.Client, newTransport http.RoundTripper) *http.Client {
base:=baseClient.Transportifbase==nil {
base=http.DefaultTransport
}
_=base// newTransport already has base captured by callerclone:=*baseClientclone.Transport=newTransportreturn&clone
}
Then callers construct the RoundTripper themselves and pass it in:
Summary
Part of duplicate code analysis: #9098
Two functions in
internal/mcp/http_transport_client.goshare an identical 6-line core for cloning anhttp.Clientand assigning a new transport. This core could be extracted into a private helper.Duplication Details
Pattern:
http.Clientshallow clone + transport assignmentSeverity: Medium
Occurrences: 2 instances (6 lines each)
Locations:
internal/mcp/http_transport_client.golines ~57–63 (insidebuildHTTPClientWithHeaders)internal/mcp/http_transport_client.golines ~93–103 (insidebuildHTTPClientWithOIDC)Code Sample:
The only difference is the concrete
RoundTrippertype assigned toclone.Transport.Impact Analysis
Refactoring Recommendations
cloneClientWithTransporthelper:RoundTripperthemselves and pass it in:Implementation Checklist
cloneClientWithTransporthelper inhttp_transport_client.gobuildHTTPClientWithHeadersto use itbuildHTTPClientWithOIDCto use itmake testto verify no behavioral changesParent Issue
See parent analysis report: #9098
Related to #9098
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpgSee Network Configuration for more information.