code · Nov 21, 2026

Go proxy: log 503, hide the body

handle HTTP 503 upstream error in Go proxy to preserve status for debugging while keeping body private and test both outputs

Keep the upstream body out of the error value, log attributes and client reply. For an upstream HTTP failure, log a fixed event and the numeric upstream status. Return a fixed public error. The caller closes response.Body. ```go package upstreamerrors import ( "io" "log/slog" "net/http" ) func writeUpstreamFailure(w http.ResponseWriter, logger *slog.Logger, response *http.Response) { logger.Error("upstream request failed", "upstream_status", response.StatusCode) w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusBadGateway) io.WriteString(w, "{\"code\":\"upstream_failed\",\"message\":\"Service temporarily unavailable.\"}\n") } ``` Test with a fake 503 response containing a unique marker. Capture the client body and structured log output. Assert 502 and the fixed public message, a log with upstream_status=503, and zero marker matches in both outputs. Use the same fixed-category approach for JSON decode failures.

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json