rqlite/rqlite · error
failed to parse endpoint URL: %w
Error message
failed to parse endpoint URL: %w
What it means
NewSink parses the configured CDC endpoint with url.Parse; this error wraps a parse failure. It fires only for endpoints other than the literal 'stdout', when the string is not a valid URL at all (malformed percent-encoding, control characters, invalid IPv6 literals, etc.).
Source
Thrown at cdc/sink.go:117
if d.httpClient != nil {
d.httpClient.CloseIdleConnections()
}
return nil
}
func (d *HTTPSink) String() string {
return httpurl.RemoveBasicAuth(d.endpoint)
}
// NewSink creates a new Sink based on the provided configuration.
func NewSink(cfg SinkConfig) (Sink, error) {
if strings.EqualFold(cfg.Endpoint, "stdout") {
return NewStdoutSink(), nil
}
u, err := url.Parse(cfg.Endpoint)
if err != nil {
return nil, fmt.Errorf("failed to parse endpoint URL: %w", err)
}
switch u.Scheme {
case "http", "https":
return NewHTTPSink(cfg.Endpoint, cfg.TLSConfig, cfg.TransmitTimeout), nil
default:
return nil, fmt.Errorf("cdc: unsupported scheme %q", u.Scheme)
}
}
View on GitHub (pinned to 7586a4d1bd)
Solutions
- Validate the endpoint with url.Parse in your own config loader before constructing the service
- Escape or percent-encode special characters in the endpoint
- Check for stray whitespace/control characters introduced by shell or YAML config
Example fix
// before endpoint := "http://collector.example.com/hook %20" // after endpoint := "http://collector.example.com/hook%20path"
Defensive patterns
Strategy: validation
Validate before calling
if _, err := url.Parse(cfg.Endpoint); err != nil {
return fmt.Errorf("bad CDC endpoint %q: %w", cfg.Endpoint, err)
} Type guard
func isValidEndpoint(s string) bool {
if strings.EqualFold(s, "stdout") {
return true
}
u, err := url.Parse(s)
return err == nil && (u.Scheme == "http" || u.Scheme == "https")
} Try / catch
sink, err := cdc.NewSink(cfg)
if err != nil {
return fmt.Errorf("CDC config rejected: %w", err)
} Prevention
- Validate the endpoint with url.Parse at config-load time
- Reject endpoints containing raw spaces or control characters
- Build URLs programmatically with url.URL instead of string concatenation
When it happens
Trigger: Passing a SinkConfig.Endpoint that url.Parse rejects, e.g. 'http://[::1' (unclosed bracket), 'http://host:port' (non-numeric port is accepted by Parse but caught later — true parse failures are things like bad escapes '%zz' or control chars in the URL).
Common situations: Hand-edited config with a stray character or unescaped space, shell variable interpolation producing an empty/garbled URL, copying a URL with hidden control characters.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- cdc: unsupported scheme %q
- ErrUnsupportedStorageType
- ErrInvalidInterval
- event cannot be nil
- interval must be greater than zero
AI-assisted analysis of rqlite/rqlite@7586a4d1bd (2026-09-03).
Data as JSON: /api/errors/df8515124d01f3fc.
Report an issue: GitHub.