chenhg5/cc-connect · error
reasonix: create request: %w
Error message
reasonix: create request: %w
What it means
httpPost builds the POST request with http.NewRequestWithContext against s.serveURL+path. Failure here (wrapped as 'reasonix: create request: %w') means the request could not even be constructed — almost always a malformed URL. The context itself comes from the session, so a canceled context does NOT fail here (it fails later at Do).
Source
Thrown at agent/reasonix/session.go:486
return
}
s.emit(core.Event{Type: core.EventThinking, Content: text})
}
// httpPost sends a JSON POST request to the reasonix serve endpoint.
func (s *reasonixSession) httpPost(path string, body any) error {
var reqBody io.Reader
if body != nil {
data, err := json.Marshal(body)
if err != nil {
return fmt.Errorf("reasonix: marshal body: %w", err)
}
reqBody = bytes.NewReader(data)
}
req, err := http.NewRequestWithContext(s.ctx, "POST", s.serveURL+path, reqBody)
if err != nil {
return fmt.Errorf("reasonix: create request: %w", err)
}
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return fmt.Errorf("reasonix: POST %s: %w", path, err)
}
defer func() {
if err := resp.Body.Close(); err != nil {
slog.Warn("reasonix: POST close body", "path", path, "error", err)
}
}()
if resp.StatusCode >= 400 {
// Include response body (first 512 bytes) in error for debugging.
errBody, _ := io.ReadAll(io.LimitReader(resp.Body, 512))
return fmt.Errorf("reasonix: POST %s returned %d: %s", path, resp.StatusCode, strings.TrimSpace(string(errBody)))
}View on GitHub (pinned to 4000b2338a)
Solutions
- Print/check s.serveURL — validate it with url.Parse before creating the session
- Fix the serve_url value in config.toml to a full absolute URL including scheme, e.g. http://127.0.0.1:8080
- Reject empty or relative serve URLs at agent construction with a clear config error
Example fix
// before
serveURL := "localhost:8080" // no scheme
// after
u, err := url.Parse(cfg.ServeURL)
if err != nil || u.Scheme == "" || u.Host == "" {
return nil, fmt.Errorf("reasonix: invalid serve_url %q", cfg.ServeURL)
} Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(serveURL)
if err != nil || u.Scheme == "" || u.Host == "" {
return fmt.Errorf("invalid serve_url %q", serveURL)
} Try / catch
// Go
if err := sess.Send(...); err != nil {
if strings.Contains(err.Error(), "create request") {
slog.Error("reasonix serve_url malformed", "err", err)
}
} Prevention
- Always include scheme+host in serve_url (http://127.0.0.1:PORT)
- Validate URLs at config load time, not at request time
- Use url.JoinPath instead of raw string concatenation for paths
When it happens
Trigger: s.serveURL is malformed (bad scheme, spaces, control characters, unparseable host) so http.NewRequestWithContext returns an error when parsing the combined URL, during newSession, Send, or RespondPermission.
Common situations: serve_url in config.toml missing the http:// scheme, containing a trailing path with spaces, or being built by string concatenation with an empty base producing a relative URL like '/session'.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- create request: %w
- gemini stt: create request: %w
- yuanbao: create request: %w
- url is required for type=http
- providerproxy: parse target: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/232c33b0a7a75c4f.
Report an issue: GitHub.