{"record":{"id":"33d9eb8fc8151e33","repo":"golang/go","slug":"failed-to-compute-server-url-v","errorCode":null,"errorMessage":"failed to compute server URL: %v","messagePattern":"failed to compute server URL: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/trace/main.go","lineNumber":165,"sourceCode":"\t\tdefault:\n\t\t\tlogAndDie(fmt.Errorf(\"invalid debug mode %s, want one of: parsed, wire, footprint\", *debugFlag))\n\t\t}\n\t}\n\n\taddr, err := listenAddr(*httpFlag)\n\tif err != nil {\n\t\tlogAndDie(fmt.Errorf(\"malformed -http value %q: %v\", *httpFlag, err))\n\t}\n\n\tln, err := net.Listen(\"tcp\", addr)\n\tif err != nil {\n\t\tlogAndDie(fmt.Errorf(\"failed to create server socket: %w\", err))\n\t}\n\n\taddr = ln.Addr().String()\n\turl, simplified, err := addrURL(addr)\n\tif err != nil {\n\t\tlogAndDie(fmt.Errorf(\"failed to compute server URL: %v\", err))\n\t}\n\n\tlog.Print(\"Preparing trace for viewer...\")\n\tparsed, err := parseTraceInteractive(tracef, traceSize)\n\tif err != nil {\n\t\tlogAndDie(err)\n\t}\n\t// N.B. tracef not needed after this point.\n\t// We might double-close, but that's fine; we ignore the error.\n\ttracef.Close()\n\n\t// Print a nice message for a partial trace.\n\tif parsed.err != nil {\n\t\tlog.Printf(\"Encountered error, but able to proceed. Error: %v\", parsed.err)\n\n\t\tlost := parsed.size - parsed.valid\n\t\tpct := float64(lost) / float64(parsed.size) * 100\n\t\tlog.Printf(\"Lost %.2f%% of the latest trace data due to error (%s of %s)\", pct, byteCount(lost), byteCount(parsed.size))","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/trace/main.go#L147-L183","documentation":"Once the listener is up, `addrURL(addr)` converts the bound address into an `http://...` URL by calling `net.SplitHostPort` again on the listener's resolved address. If the resolved `ln.Addr().String()` cannot be split into host:port (extremely unlikely for a TCP listener), the URL computation fails and the tool aborts before serving. This is a defensive guard around an expected-invariant case.","triggerScenarios":"Effectively only if `net.Listener.Addr().String()` returns a malformed string, which does not happen for standard TCP listeners. Could occur with a custom/intercepted net.Listener in a fork, or on platforms whose net package returns nonstandard address formatting.","commonSituations":"Rare in stock Go; seen when a third-party wrapper proxies the listener (e.g., a custom dialer/library that fakes listener addresses), or in stripped/odd toolchain builds.","solutions":["Retry with a plain `-http=localhost:<port>` to ensure a normal TCP listener address.","Update/repair the Go toolchain — a malformed listener address indicates a toolchain or platform bug.","If running a patched tool, ensure the listener's Addr() returns a valid host:port string."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, _, err := net.SplitHostPort(ln.Addr().String()); err != nil {\n    log.Printf(\"listener returned unexpected address format: %v\", err)\n}","preventionTips":["Use a stock net.Listener; do not wrap it with custom Addr() implementations.","Keep your Go toolchain current."],"tags":["network","go-tool-trace","defensive","internal-invariant"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}