{"record":{"id":"875ed3960458fe8b","repo":"nsqio/nsq","slug":"address-should-not-contain-scheme","errorCode":null,"errorMessage":"address should not contain scheme","messagePattern":"address should not contain scheme","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/nsq_stat/nsq_stat.go","lineNumber":126,"sourceCode":"\t\t\tc.MemoryDepth,\n\t\t\tc.BackendDepth,\n\t\t\tc.InFlightCount,\n\t\t\tc.DeferredCount,\n\t\t\tc.RequeueCount,\n\t\t\tc.TimeoutCount,\n\t\t\tc.MessageCount,\n\t\t\tc.ClientCount)\n\n\t\to = c\n\t\ttime.Sleep(interval)\n\t}\n\tos.Exit(0)\n}\n\nfunc checkAddrs(addrs []string) error {\n\tfor _, a := range addrs {\n\t\tif strings.HasPrefix(a, \"http\") {\n\t\t\treturn errors.New(\"address should not contain scheme\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc main() {\n\tflag.Parse()\n\n\tif *showVersion {\n\t\tfmt.Printf(\"nsq_stat v%s\\n\", version.Binary)\n\t\treturn\n\t}\n\n\tif *topic == \"\" || *channel == \"\" {\n\t\tlog.Fatal(\"--topic and --channel are required\")\n\t}\n\n\tintvl := *interval","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/nsqio/nsq/blob/85cf10c09c6c3c86160d6f0eb156f62d0efc1648/apps/nsq_stat/nsq_stat.go#L108-L144","documentation":"nsq_stat validates the addresses passed to --nsqd-http-address (and --lookupd-http-address) via checkAddrs and rejects any value with an 'http' prefix. The tool builds the HTTP URL itself from a bare host:port, so a scheme in the input would produce a malformed URL like http://http://host:port. On failure main() exits immediately with log.Fatalf.","triggerScenarios":"Running apps/nsq_stat with a flag value such as --nsqd-http-address=http://127.0.0.1:4151 or --lookupd-http-address=https://lookup:4161. strings.HasPrefix(a, \"http\") matches both http and https prefixes, and only the first offending address is reported before the process dies.","commonSituations":"Copy-pasting a health-check or browser URL into the flag; migrating scripts that used curl http://...; wrapping nsq_stat in tooling that normalizes addresses as URLs. Users coming from nsqadmin docs where URLs appear frequently.","solutions":["Remove the scheme: use --nsqd-http-address=127.0.0.1:4151 (host:port only).","If several addresses are given, strip http:// or https:// from every one; checkAddrs fails on the first match it finds.","If a reverse proxy or TLS terminator fronts nsqd, point nsq_stat at the plain host:port it can reach, or fix the proxy config rather than adding a scheme."],"exampleFix":"# before\nnsq_stat --nsqd-http-address=http://127.0.0.1:4151 --topic=test --interval=5s\n# after\nnsq_stat --nsqd-http-address=127.0.0.1:4151 --topic=test --interval=5s","handlingStrategy":"validation","validationCode":"func normalizeAddr(a string) string {\n\tfor _, p := range []string{\"https://\", \"http://\"} {\n\t\ta = strings.TrimPrefix(strings.TrimSpace(a), p)\n\t}\n\treturn strings.TrimSuffix(a, \"/\")\n}\n\nfor i, a := range nsqdHTTPAddrs {\n\tnsqdHTTPAddrs[i] = normalizeAddr(a) // pass host:port to --nsqd-http-address\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a single helper that formats nsq HTTP flags as host:port and use it in all scripts.","In CI smoke tests, assert that generated nsq_stat/nsqadmin command lines contain no 'http://' inside address flags."],"tags":["go","nsq","cli","config","validation"],"backgroundTag":null,"analyzedSha":"85cf10c09c6c3c86160d6f0eb156f62d0efc1648","analyzedAt":"2026-08-16T00:53:05.009Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}