Eliminate duplicate code in authorization parsing and HTTP transport connection #388
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Analysis identified 3 duplication patterns totaling ~80 lines. This PR eliminates patterns #1 and #2 (~70 lines), defers #3 as idiomatic Go.
Changes
Authorization Header Parsing
auth.ExtractSessionID()routed.goandtransport.goBefore:
After:
HTTP Transport Connection Boilerplate
trySDKTransport()with function parameter patterntryStreamableHTTPTransportandtrySSETransportfrom ~27 lines each to ~9 linesBefore:
After:
Error Wrapping Pattern
Evaluated 67 instances of
fmt.Errorf("failed to %s: %w", ...)pattern. No changes - this is idiomatic Go where each error provides unique debugging context.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:
this-host-does-not-exist-12345.com/tmp/go-build486373954/b278/mcp.test /tmp/go-build486373954/b278/mcp.test -test.testlogfile=/tmp/go-build486373954/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true go riter/tabwriter.-Wl,--no-gc-sections 64/pkg/tool/linu-fmessage-length=0 r(dns block)/tmp/go-build3948523853/b001/mcp.test /tmp/go-build3948523853/b001/mcp.test -test.testlogfile=/tmp/go-build3948523853/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.5/x64/src/runtime/c-errorsas .cfg x_amd64/link(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.