{"record":{"id":"b35565caf0a43611","repo":"nsqio/nsq","slug":"failed-to-parse-graphite-url-s-s","errorCode":null,"errorMessage":"failed to parse --graphite-url (%s) - %s","messagePattern":"failed to parse --graphite-url \\((.+?)\\) - (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nsqadmin/nsqadmin.go","lineNumber":101,"sourceCode":"\n\tfor _, address := range opts.NSQLookupdHTTPAddresses {\n\t\t_, err := net.ResolveTCPAddr(\"tcp\", address)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to resolve --lookupd-http-address (%s) - %s\", address, err)\n\t\t}\n\t}\n\n\tfor _, address := range opts.NSQDHTTPAddresses {\n\t\t_, err := net.ResolveTCPAddr(\"tcp\", address)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to resolve --nsqd-http-address (%s) - %s\", address, err)\n\t\t}\n\t}\n\n\tif opts.ProxyGraphite {\n\t\turl, err := url.Parse(opts.GraphiteURL)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse --graphite-url (%s) - %s\", opts.GraphiteURL, err)\n\t\t}\n\t\tn.graphiteURL = url\n\t}\n\n\tif opts.AllowConfigFromCIDR != \"\" {\n\t\t_, _, err := net.ParseCIDR(opts.AllowConfigFromCIDR)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse --allow-config-from-cidr (%s) - %s\", opts.AllowConfigFromCIDR, err)\n\t\t}\n\t}\n\n\topts.BasePath = normalizeBasePath(opts.BasePath)\n\n\tn.logf(LOG_INFO, version.String(\"nsqadmin\"))\n\n\tvar err error\n\tn.httpListener, err = net.Listen(\"tcp\", n.getOpts().HTTPAddress)\n\tif err != nil {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/nsqio/nsq/blob/85cf10c09c6c3c86160d6f0eb156f62d0efc1648/nsqadmin/nsqadmin.go#L83-L119","documentation":"nsqadmin.New validates --graphite-url with url.Parse, but only when --proxy-graphite is enabled (nsqadmin then proxies /render requests to Graphite). url.Parse almost never fails; it only rejects structurally broken URLs, mainly strings containing control characters (0x00-0x1f, 0x7f). This error is a fatal startup error returned from the nsqadmin constructor.","triggerScenarios":"Starting nsqadmin with --proxy-graphite and a --graphite-url value that contains control characters, raw tabs/newlines, or other characters Go's URL parser refuses (e.g. a value injected from an environment variable or config file with trailing whitespace/newline).","commonSituations":"Graphite URL sourced from an env var or systemd unit that accidentally embeds a newline; copy/paste of a URL with a stray non-printable character; template interpolation (Ansible/Helm) injecting spaces or quotes; enabling --proxy-graphite without ever validating the URL.","solutions":["Print/inspect the exact --graphite-url value (cat -A or %q) to expose hidden control characters, then fix or retype it","Use a fully qualified URL such as http://graphite.example.com:80 (scheme + host)","If you do not need Graphite graph proxying in the UI, drop --proxy-graphite so the parse is skipped entirely","Pre-validate the value with url.Parse in your init system / wrapper script before launching nsqadmin"],"exampleFix":"# before (env var contains a trailing newline)\n--proxy-graphite\n--graphite-url=$GRAPHITE_URL   # value: \"http://graphite:80\\n\"\n\n# after (validated, literal value)\n--proxy-graphite\n--graphite-url=http://graphite.example.com:80","handlingStrategy":"validation","validationCode":"if opts.ProxyGraphite {\n\tif _, err := url.Parse(opts.GraphiteURL); err != nil {\n\t\tlog.Fatalf(\"bad --graphite-url %q: %v\", opts.GraphiteURL, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"n, err := nsqadmin.New(opts)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to parse --graphite-url\") {\n\t\t// config typo: fix the URL and restart; not retryable\n\t}\n\tlog.Fatal(err)\n}","preventionTips":["Render flag values with %q in logs to expose hidden control characters","Source the URL from a validated secret/config key, not ad-hoc env interpolation","Smoke-test startup in CI with the production flag set"],"tags":["nsqadmin","config","url","graphite","startup"],"backgroundTag":null,"analyzedSha":"85cf10c09c6c3c86160d6f0eb156f62d0efc1648","analyzedAt":"2026-08-16T00:53:05.009Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}