{"record":{"id":"df8515124d01f3fc","repo":"rqlite/rqlite","slug":"failed-to-parse-endpoint-url-w","errorCode":null,"errorMessage":"failed to parse endpoint URL: %w","messagePattern":"failed to parse endpoint URL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cdc/sink.go","lineNumber":117,"sourceCode":"\tif d.httpClient != nil {\n\t\td.httpClient.CloseIdleConnections()\n\t}\n\treturn nil\n}\n\nfunc (d *HTTPSink) String() string {\n\treturn httpurl.RemoveBasicAuth(d.endpoint)\n}\n\n// NewSink creates a new Sink based on the provided configuration.\nfunc NewSink(cfg SinkConfig) (Sink, error) {\n\tif strings.EqualFold(cfg.Endpoint, \"stdout\") {\n\t\treturn NewStdoutSink(), nil\n\t}\n\n\tu, err := url.Parse(cfg.Endpoint)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse endpoint URL: %w\", err)\n\t}\n\n\tswitch u.Scheme {\n\tcase \"http\", \"https\":\n\t\treturn NewHTTPSink(cfg.Endpoint, cfg.TLSConfig, cfg.TransmitTimeout), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"cdc: unsupported scheme %q\", u.Scheme)\n\t}\n}\n","sourceCodeStart":99,"sourceCodeEnd":127,"githubUrl":"https://github.com/rqlite/rqlite/blob/7586a4d1bdbd9a5a80021664c5a863cd850adb60/cdc/sink.go#L99-L127","documentation":"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.).","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nendpoint := \"http://collector.example.com/hook %20\"\n// after\nendpoint := \"http://collector.example.com/hook%20path\"","handlingStrategy":"validation","validationCode":"if _, err := url.Parse(cfg.Endpoint); err != nil {\n\treturn fmt.Errorf(\"bad CDC endpoint %q: %w\", cfg.Endpoint, err)\n}","typeGuard":"func isValidEndpoint(s string) bool {\n\tif strings.EqualFold(s, \"stdout\") {\n\t\treturn true\n\t}\n\tu, err := url.Parse(s)\n\treturn err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\")\n}","tryCatchPattern":"sink, err := cdc.NewSink(cfg)\nif err != nil {\n\treturn fmt.Errorf(\"CDC config rejected: %w\", err)\n}","preventionTips":["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"],"tags":["cdc","url","config","validation"],"backgroundTag":"invalid-url-config","analyzedSha":"7586a4d1bdbd9a5a80021664c5a863cd850adb60","analyzedAt":"2026-09-03T07:03:02.260Z","contentChangedAt":"2026-09-03T07:03:02.260Z","schemaVersion":2},"datasetVersion":"2026-09-10T12:17:11.382Z"}