chenhg5/cc-connect · error
parse ws url: %w
Error message
parse ws url: %w
What it means
wsTransport.connectOnce parses the configured wsURL with net/url.Parse before dialing; any parse failure is wrapped as 'parse ws url: %w'. This is a local configuration error — the WebSocket URL string supplied to the cloud-web platform is not a valid URL at all.
Source
Thrown at platform/cloud-web/ws.go:119
}
select {
case <-ctx.Done():
return
case <-time.After(delay):
}
if delay < wsReconnectMax {
delay *= 2
if delay > wsReconnectMax {
delay = wsReconnectMax
}
}
}
}
func (t *wsTransport) connectOnce(ctx context.Context) error {
u, err := url.Parse(t.wsURL)
if err != nil {
return fmt.Errorf("parse ws url: %w", err)
}
if t.token != "" {
q := u.Query()
if q.Get("token") == "" {
q.Set("token", t.token)
u.RawQuery = q.Encode()
}
}
header := http.Header{}
if t.token != "" {
header.Set("Authorization", "Bearer "+t.token)
header.Set("X-Cloud-Web-Token", t.token)
}
conn, _, err := websocket.DefaultDialer.DialContext(ctx, u.String(), header)
if err != nil {
return errView on GitHub (pinned to 4000b2338a)
Solutions
- Fix the wsURL value in config.toml — it must be a well-formed URL like wss://host/path
- Trim whitespace and quotes from the configured value; validate it with a quick url.Parse in a scratch program or `cc-connect doctor` if available
- Check where wsURL is assembled (resolveWSURL / env vars) for injected invalid characters
- Add startup-time validation so an invalid wsURL fails fast with the URL included in the message
Example fix
// before wsURL = "wss://hub.example.com/ws " // after wsURL = "wss://hub.example.com/ws"
Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(cfg.WSURL)
if err != nil {
return fmt.Errorf("bad cloud-web wsURL %q: %w", cfg.WSURL, err)
}
if u.Scheme != "ws" && u.Scheme != "wss" {
return fmt.Errorf("cloud-web wsURL must use ws:// or wss://, got %q", cfg.WSURL)
} Type guard
func isValidWSURL(s string) bool {
u, err := url.Parse(strings.TrimSpace(s))
return err == nil && (u.Scheme == "ws" || u.Scheme == "wss") && u.Host != ""
} Try / catch
// Fail fast at startup, not at connect time
if !isValidWSURL(cfg.WSURL) {
return fmt.Errorf("config: invalid cloud-web wsURL %q", cfg.WSURL)
} Prevention
- Trim whitespace/quotes from URLs pasted into config
- Validate wsURL at config-load time with url.Parse
- Prefer wss:// in production; avoid hand-assembling URLs from env vars
- Run `cc-connect doctor` or equivalent config validation before launch
When it happens
Trigger: url.Parse(t.wsURL) returns an error due to malformed URL syntax: control characters, bad percent-encoding, spaces, or otherwise unparseable text in the configured wsURL.
Common situations: Typo or unescaped characters in config.toml ws URL; environment variable interpolation producing garbage; trailing whitespace/quotes pasted into config; TOML multi-line string accidentally including newlines.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- cloud_web: ws_url or base_url is required for websocket tran
- reasonix: create request: %w
- providerproxy: parse target: %w
- create request: %w
- gemini stt: create request: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/a14c918ce4b97448.
Report an issue: GitHub.