Skip to content

refactor: extract logOutboundRPCRequest helper; complete flags.go env-var table#3888

Merged
lpcox merged 2 commits intomainfrom
copilot/duplicate-code-analysis-report
Apr 15, 2026
Merged

refactor: extract logOutboundRPCRequest helper; complete flags.go env-var table#3888
lpcox merged 2 commits intomainfrom
copilot/duplicate-code-analysis-report

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

Two low-to-medium severity duplication patterns identified in commit ca03645. The inbound response logging was already abstracted into logInboundRPCResponse; the outbound request side was left inline, and the flags.go helper table was missing its tracing entries.

Changes

  • internal/mcp/connection.go — Extract logOutboundRPCRequest helper, symmetric with the existing logInboundRPCResponse. Replaces the inline if shouldAttachAgentTags block in SendRequestWithServerID:

    // Before
    if shouldAttachAgentTags {
        logger.LogRPCRequestWithAgentSnapshot(logger.RPCDirectionOutbound, serverID, method, requestPayload, snapshot.Secrecy, snapshot.Integrity)
    } else {
        logger.LogRPCRequest(logger.RPCDirectionOutbound, serverID, method, requestPayload)
    }
    
    // After
    logOutboundRPCRequest(serverID, method, requestPayload, shouldAttachAgentTags, snapshot)
  • internal/cmd/flags.go — Add the two missing tracing helpers to the getDefault* inventory table (getDefaultOTLPEndpointOTEL_EXPORTER_OTLP_ENDPOINT, getDefaultOTLPServiceNameOTEL_SERVICE_NAME). The one-liner-per-file pattern remains intentional; this is a documentation completeness fix.

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-build540237260/b514/launcher.test /tmp/go-build540237260/b514/launcher.test -test.testlogfile=/tmp/go-build540237260/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s E=3 t.go olang.org/grpc@v-ifaceassert x_amd64/compile . /tmp/cgo-gcc-inp/usr/bin/runc x_amd64/asm x_amd64/compile -I cfg -I x_amd64/vet --gdwarf-5 g/grpc/connectiv/usr/bin/runc -o x_amd64/vet (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build540237260/b496/config.test /tmp/go-build540237260/b496/config.test -test.testlogfile=/tmp/go-build540237260/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build540237260/b394/vet.cfg @v1.1.3/cpu/x86/go1.25.8 -I x_amd64/vet --gdwarf-5 ing/prototext -o x_amd64/vet -I ify@v1.11.1/asse-errorsas ify@v1.11.1/asse-ifaceassert x_amd64/vet --gdwarf-5 telabs/wazero/in-atomic -o x_amd64/vet (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build540237260/b514/launcher.test /tmp/go-build540237260/b514/launcher.test -test.testlogfile=/tmp/go-build540237260/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s E=3 t.go olang.org/grpc@v-ifaceassert x_amd64/compile . /tmp/cgo-gcc-inp/usr/bin/runc x_amd64/asm x_amd64/compile -I cfg -I x_amd64/vet --gdwarf-5 g/grpc/connectiv/usr/bin/runc -o x_amd64/vet (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build540237260/b514/launcher.test /tmp/go-build540237260/b514/launcher.test -test.testlogfile=/tmp/go-build540237260/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s E=3 t.go olang.org/grpc@v-ifaceassert x_amd64/compile . /tmp/cgo-gcc-inp/usr/bin/runc x_amd64/asm x_amd64/compile -I cfg -I x_amd64/vet --gdwarf-5 g/grpc/connectiv/usr/bin/runc -o x_amd64/vet (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build540237260/b523/mcp.test /tmp/go-build540237260/b523/mcp.test -test.testlogfile=/tmp/go-build540237260/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s -I cfg om/modelcontextprotocol/go-sdk@v1.5.0/mcp/cmd.go x_amd64/vet --gdwarf-5 g/grpc/grpclog/i-test.testlogfile=/tmp/go-build540237260/b508/testlog.txt -o x_amd64/vet cfg 0015561/b465/_pkg_.a -o/tmp/go-build1700015561/b288//-ifaceassert x_amd64/vet -c /cobra /tmp/go-build1700015561/b288/ _txqEVX/1qvAIR51hsPXl6lP0GEp (dns block)

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

Copilot AI linked an issue Apr 15, 2026 that may be closed by this pull request
@lpcox lpcox marked this pull request as ready for review April 15, 2026 17:28
Copilot AI changed the title [WIP] Add duplicate code analysis report for Go files refactor: extract logOutboundRPCRequest helper; complete flags.go env-var table Apr 15, 2026
Copilot AI review requested due to automatic review settings April 15, 2026 17:28
Copilot AI requested a review from lpcox April 15, 2026 17:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 small duplication in MCP request logging by extracting an outbound RPC logging helper to mirror the existing inbound helper, and it completes the CLI flag helper-to-env-var inventory comment for tracing defaults.

Changes:

  • Extract logOutboundRPCRequest in internal/mcp/connection.go and use it from SendRequestWithServerID to match the existing inbound response helper.
  • Update internal/cmd/flags.go’s getDefault* helper table to include the tracing helpers and their environment variables.
Show a summary per file
File Description
internal/mcp/connection.go Adds logOutboundRPCRequest helper and replaces inline outbound logging block in SendRequestWithServerID.
internal/cmd/flags.go Completes the documented mapping for tracing-related getDefault* helpers to OTEL env vars.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@lpcox lpcox merged commit c42ad84 into main Apr 15, 2026
30 checks passed
@lpcox lpcox deleted the copilot/duplicate-code-analysis-report branch April 15, 2026 17:44
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 Analysis Report

3 participants