{"record":{"id":"e97c303b90c57ad8","repo":"vitessio/vitess","slug":"failed-to-parse-opentsdb-uri-s-v","errorCode":null,"errorMessage":"failed to parse --opentsdb-uri %s: %v","messagePattern":"failed to parse --opentsdb-uri (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/stats/opentsdb/init.go","lineNumber":87,"sourceCode":"\t\t} else {\n\t\t\tw.Write(b)\n\t\t}\n\t})\n\n\treturn b, nil\n}\n\nfunc newBackend(prefix string) (*backend, error) {\n\tif openTSDBURI == \"\" {\n\t\treturn nil, errors.New(\"cannot create opentsdb PushBackend with empty --opentsdb-uri\")\n\t}\n\n\tvar w writer\n\n\t// Use the file API when the uri is in format file://...\n\tu, err := url.Parse(openTSDBURI)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse --opentsdb-uri %s: %v\", openTSDBURI, err)\n\t} else if u.Scheme == \"file\" {\n\t\tfw, err := newFileWriter(u.Path)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create file-based writer for --opentsdb-uri %s: %v\", openTSDBURI, err)\n\t\t} else {\n\t\t\tw = fw\n\t\t}\n\t} else {\n\t\tw = newHTTPWriter(&http.Client{}, openTSDBURI)\n\t}\n\n\treturn &backend{\n\t\tprefix:     prefix,\n\t\tcommonTags: stats.ParseCommonTags(stats.CommonTags),\n\t\twriter:     w,\n\t}, nil\n}\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/stats/opentsdb/init.go#L69-L105","documentation":"newBackend in go/stats/opentsdb/init.go parses the --opentsdb-uri flag with net/url.Parse and returns this error when parsing fails. It wraps the underlying URL parse error with the flag value so the misconfiguration is obvious at startup.","triggerScenarios":"Passing a malformed --opentsdb-uri value (e.g. \"http://[::1\", \"%zz\", or control characters) so url.Parse returns an error.","commonSituations":"Hand-edited config files with unescaped characters; missing scheme typos combined with invalid characters; shell quoting stripping needed characters.","solutions":["Correct --opentsdb-uri to a valid URL, e.g. http://opentsdb-host:4242 or file:///path/to/metrics","Percent-encode special characters (spaces, %, brackets) in the URI","Validate the URI with url.Parse in a quick Go snippet or linter before deploying"],"exampleFix":"// before\n--opentsdb-uri 'http://[::1:4242' // invalid\n// after\n--opentsdb-uri 'http://127.0.0.1:4242'","handlingStrategy":"validation","validationCode":"if _, err := url.Parse(opentsdbURI); err != nil {\n\treturn fmt.Errorf(\"invalid --opentsdb-uri %q: %v\", opentsdbURI, err)\n}","typeGuard":null,"tryCatchPattern":"backend, err := newBackend()\nif err != nil {\n\tlog.Error(\"opentsdb init failed\", slog.Any(\"error\", err))\n\tos.Exit(1)\n}","preventionTips":["Validate URIs at config-load time, before process start","Percent-encode special characters in the URI","Keep opentsdb URI in a template checked with a URL lint in CI"],"tags":["go","opentsdb","configuration","url-parsing"],"backgroundTag":"invalid-uri-flag","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}