vitessio/vitess · error

failed to parse --opentsdb-uri %s: %v

Error message

failed to parse --opentsdb-uri %s: %v

What it means

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.

Source

Thrown at go/stats/opentsdb/init.go:87

		} else {
			w.Write(b)
		}
	})

	return b, nil
}

func newBackend(prefix string) (*backend, error) {
	if openTSDBURI == "" {
		return nil, errors.New("cannot create opentsdb PushBackend with empty --opentsdb-uri")
	}

	var w writer

	// Use the file API when the uri is in format file://...
	u, err := url.Parse(openTSDBURI)
	if err != nil {
		return nil, fmt.Errorf("failed to parse --opentsdb-uri %s: %v", openTSDBURI, err)
	} else if u.Scheme == "file" {
		fw, err := newFileWriter(u.Path)
		if err != nil {
			return nil, fmt.Errorf("failed to create file-based writer for --opentsdb-uri %s: %v", openTSDBURI, err)
		} else {
			w = fw
		}
	} else {
		w = newHTTPWriter(&http.Client{}, openTSDBURI)
	}

	return &backend{
		prefix:     prefix,
		commonTags: stats.ParseCommonTags(stats.CommonTags),
		writer:     w,
	}, nil
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Correct --opentsdb-uri to a valid URL, e.g. http://opentsdb-host:4242 or file:///path/to/metrics
  2. Percent-encode special characters (spaces, %, brackets) in the URI
  3. Validate the URI with url.Parse in a quick Go snippet or linter before deploying

Example fix

// before
--opentsdb-uri 'http://[::1:4242' // invalid
// after
--opentsdb-uri 'http://127.0.0.1:4242'
Defensive patterns

Strategy: validation

Validate before calling

if _, err := url.Parse(opentsdbURI); err != nil {
	return fmt.Errorf("invalid --opentsdb-uri %q: %v", opentsdbURI, err)
}

Try / catch

backend, err := newBackend()
if err != nil {
	log.Error("opentsdb init failed", slog.Any("error", err))
	os.Exit(1)
}

Prevention

When it happens

Trigger: Passing a malformed --opentsdb-uri value (e.g. "http://[::1", "%zz", or control characters) so url.Parse returns an error.

Common situations: Hand-edited config files with unescaped characters; missing scheme typos combined with invalid characters; shell quoting stripping needed characters.

Understand the failure class

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/e97c303b90c57ad8. Report an issue: GitHub.