Skip to content

Fix duplicate HTTP request/response log statements between sendHTTPRequest and executeHTTPRequest - #4606

Merged
lpcox merged 4 commits into
mainfrom
copilot/fix-duplicate-http-logging
Apr 27, 2026
Merged

Fix duplicate HTTP request/response log statements between sendHTTPRequest and executeHTTPRequest#4606
lpcox merged 4 commits into
mainfrom
copilot/fix-duplicate-http-logging

Conversation

Copilot AI commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

sendHTTPRequest and its callee executeHTTPRequest both logged HTTP request dispatch and response receipt, producing 4 log lines per round-trip under DEBUG=mcp:* instead of 2.

Changes

  • internal/mcp/http_transport.go: The logConn.Printf calls for "Sending HTTP request" and "Received HTTP response" in sendHTTPRequest are now guarded with !logHTTP.Enabled(), preventing duplicate output when the more-detailed mcp:http_transport logger is active while preserving mcp:connection visibility when it is not:
if !logHTTP.Enabled() {
    logConn.Printf("Sending HTTP request to %s: method=%s, id=%d", c.httpURL, method, requestID)
}
result, err := c.executeHTTPRequest(...)
if !logHTTP.Enabled() {
    logConn.Printf("Received HTTP response: status=%d, body_len=%d", result.StatusCode, len(result.ResponseBody))
}

This means:

  • DEBUG=mcp:* — only logHTTP fires (no duplicates)
  • DEBUG=mcp:connectionlogConn fires as before (single pair per round-trip)
  • DEBUG=mcp:http_transport — only logHTTP fires (no duplicates)

Copilot AI changed the title [WIP] Fix duplicate HTTP request/response logging in http_transport.go Remove duplicate HTTP request/response log statements from sendHTTPRequest Apr 26, 2026
Copilot AI requested a review from lpcox April 26, 2026 22:35
@lpcox
lpcox marked this pull request as ready for review April 27, 2026 00:27
Copilot AI review requested due to automatic review settings April 27, 2026 00:27

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

This PR reduces duplicate HTTP request/response debug logging by removing the “Sending HTTP request …” and “Received HTTP response …” logConn.Printf statements from sendHTTPRequest, relying on executeHTTPRequest’s logging instead.

Changes:

  • Removed connection-namespace send/receive log lines from sendHTTPRequest to avoid duplicate per-round-trip logs.
  • Left executeHTTPRequest as the single source of “request executing” / “response received” HTTP logs.
Show a summary per file
File Description
internal/mcp/http_transport.go Removes duplicate request/response log statements from sendHTTPRequest to reduce log noise.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines 645 to 648
requestID := atomic.AddUint64(&requestIDCounter, 1)
logConn.Printf("Sending HTTP request to %s: method=%s, id=%d", c.httpURL, method, requestID)

result, err := c.executeHTTPRequest(ctx, method, params, requestID, headerModifier)
if err != nil {

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing the request/response logs here, HTTP round-trip visibility now depends entirely on the mcp:http_transport logger (i.e., DEBUG=mcp:connection will no longer show any per-request send/receive lines). If the intent is only to remove duplicates under DEBUG=mcp:* while preserving the existing mcp:connection behavior, consider emitting the logConn lines conditionally (e.g., only when !logHTTP.Enabled()), or otherwise ensuring the connection-level logger still provides a single request/response pair.

Copilot uses AI. Check for mistakes.
@lpcox

lpcox commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

@copilot address this review feedback #4606 (review)

Copilot AI commented Apr 27, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address this review feedback #4606 (review)

Addressed in 6b00f8f. The logConn send/receive lines are now guarded with !logHTTP.Enabled():

  • DEBUG=mcp:* → only logHTTP fires (no duplicates)
  • DEBUG=mcp:connectionlogConn fires as before (single pair per round-trip)
  • DEBUG=mcp:http_transport → only logHTTP fires

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /tmp/go-build629936415/b509/launcher.test /tmp/go-build629936415/b509/launcher.test -test.testlogfile=/tmp/go-build629936415/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true aw-mcpg/internal-p cfg x_amd64/compile (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build629936415/b491/config.test /tmp/go-build629936415/b491/config.test -test.testlogfile=/tmp/go-build629936415/b491/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/runtime/c-p 6UTz/5ecS_4XL9_qgoogle.golang.org/grpc/internal x_amd64/compile (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build629936415/b509/launcher.test /tmp/go-build629936415/b509/launcher.test -test.testlogfile=/tmp/go-build629936415/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true aw-mcpg/internal-p cfg x_amd64/compile (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build629936415/b509/launcher.test /tmp/go-build629936415/b509/launcher.test -test.testlogfile=/tmp/go-build629936415/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true aw-mcpg/internal-p cfg x_amd64/compile (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build629936415/b518/mcp.test /tmp/go-build629936415/b518/mcp.test -test.testlogfile=/tmp/go-build629936415/b518/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true se cfg ache/go/1.25.9/x-nilfunc -p go.opentelemetry-atomic -lang=go1.25 ache/go/1.25.9/x-buildtags (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Remove duplicate HTTP request/response log statements from sendHTTPRequest Fix duplicate HTTP request/response log statements between sendHTTPRequest and executeHTTPRequest Apr 27, 2026
@lpcox
lpcox merged commit 9e17189 into main Apr 27, 2026
16 checks passed
@lpcox
lpcox deleted the copilot/fix-duplicate-http-logging branch April 27, 2026 00:42
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: Double-logged HTTP request/response round-trip messages

3 participants