Skip to content

Commit abf04a8

Browse files
authored
Fix golangci-lint CI failures in internal/proxy/handler.go (#2189)
Two staticcheck violations introduced in `internal/proxy/handler.go` were causing the lint CI job to fail. ## Changes - **Remove `forwardGraphQL`**: Dead code — defined but never called. GraphQL forwarding is handled inline in `handleWithDIFC`. - **Fix S1034 type switch**: Eliminate redundant type assertion inside the `map[string]interface{}` case by using the idiomatic assigned type switch form: ```go // Before switch originalData.(type) { case map[string]interface{}: obj := originalData.(map[string]interface{}) // redundant assertion ... } // After switch obj := originalData.(type) { case map[string]interface{}: // obj is already the asserted type ... } ``` > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `example.com` > - Triggering command: `/tmp/go-build1696049945/b333/launcher.test /tmp/go-build1696049945/b333/launcher.test -test.testlogfile=/tmp/go-build1696049945/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1696049945/b238/vet.cfg go o x_amd64/compile` (dns block) > - `invalid-host-that-does-not-exist-12345.com` > - Triggering command: `/tmp/go-build1696049945/b318/config.test /tmp/go-build1696049945/b318/config.test -test.testlogfile=/tmp/go-build1696049945/b318/testlog.txt -test.paniconexit0 -test.timeout=10m0s ncod�� 64/src/runtime/cgo 64/src/encoding/asn1/asn1.go x_amd64/asm` (dns block) > - `nonexistent.local` > - Triggering command: `/tmp/go-build1696049945/b333/launcher.test /tmp/go-build1696049945/b333/launcher.test -test.testlogfile=/tmp/go-build1696049945/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1696049945/b238/vet.cfg go o x_amd64/compile` (dns block) > - `slow.example.com` > - Triggering command: `/tmp/go-build1696049945/b333/launcher.test /tmp/go-build1696049945/b333/launcher.test -test.testlogfile=/tmp/go-build1696049945/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1696049945/b238/vet.cfg go o x_amd64/compile` (dns block) > - `this-host-does-not-exist-12345.com` > - Triggering command: `/tmp/go-build1696049945/b342/mcp.test /tmp/go-build1696049945/b342/mcp.test -test.testlogfile=/tmp/go-build1696049945/b342/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1696049945/b215/vet.cfg p/go-build linux.go x_amd64/compile --exclude-hidden/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet terpreter --quiet x_amd64/compile 2599�� ache/go/1.25.8/x-errorsas AcPk/Gl1SDLLxjjl-ifaceassert x_amd64/vet` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/github/gh-aw-mcpg/settings/copilot/coding_agent) (admins only) > > </details> <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Fix the failing GitHub Actions workflow lint > Analyze the workflow logs, identify the root cause of the failure, and implement a fix. > Job ID: 67821217215 > Job URL: https://github.com/github/gh-aw-mcpg/actions/runs/23317651473/job/67821217215 </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.
2 parents b613ed0 + 4235e47 commit abf04a8

1 file changed

Lines changed: 1 addition & 20 deletions

File tree

internal/proxy/handler.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,6 @@ func (h *proxyHandler) passthrough(w http.ResponseWriter, r *http.Request, path
291291
h.writeResponse(w, resp, respBody)
292292
}
293293

294-
// forwardGraphQL forwards a GraphQL request without DIFC filtering.
295-
func (h *proxyHandler) forwardGraphQL(w http.ResponseWriter, r *http.Request, _ string, body []byte) {
296-
resp, err := h.server.forwardToGitHub(r.Context(), http.MethodPost, "/graphql", bytes.NewReader(body), "application/json")
297-
if err != nil {
298-
http.Error(w, "upstream request failed", http.StatusBadGateway)
299-
return
300-
}
301-
defer resp.Body.Close()
302-
303-
respBody, err := io.ReadAll(resp.Body)
304-
if err != nil {
305-
http.Error(w, "failed to read upstream response", http.StatusBadGateway)
306-
return
307-
}
308-
309-
h.writeResponse(w, resp, respBody)
310-
}
311-
312294
// writeResponse writes an upstream response to the client.
313295
func (h *proxyHandler) writeResponse(w http.ResponseWriter, resp *http.Response, body []byte) {
314296
copyResponseHeaders(w, resp)
@@ -326,11 +308,10 @@ func (h *proxyHandler) writeEmptyResponse(w http.ResponseWriter, resp *http.Resp
326308
w.WriteHeader(resp.StatusCode)
327309

328310
var empty string
329-
switch originalData.(type) {
311+
switch obj := originalData.(type) {
330312
case []interface{}:
331313
empty = "[]"
332314
case map[string]interface{}:
333-
obj := originalData.(map[string]interface{})
334315
// GraphQL responses wrap their payload in a "data" key
335316
if _, ok := obj["data"]; ok {
336317
empty = `{"data":null}`

0 commit comments

Comments
 (0)