chenhg5/cc-connect · error
url must start with http:// or https://
Error message
url must start with http:// or https://
What it means
For http-type hooks, validateHookConfig additionally enforces that the URL uses http:// or https://. Arbitrary schemes (file://, ftp://, custom schemes) are rejected to prevent misuse of the HTTP client.
Source
Thrown at core/hooks.go:121
client: &http.Client{},
}
}
func validateHookConfig(h HookConfig) error {
if h.Event == "" {
return fmt.Errorf("event is required")
}
switch HookHandlerType(h.Type) {
case HookHandlerCommand:
if h.Command == "" {
return fmt.Errorf("command is required for type=command")
}
case HookHandlerHTTP:
if h.URL == "" {
return fmt.Errorf("url is required for type=http")
}
if !strings.HasPrefix(h.URL, "http://") && !strings.HasPrefix(h.URL, "https://") {
return fmt.Errorf("url must start with http:// or https://")
}
default:
return fmt.Errorf("unknown handler type %q (must be command or http)", h.Type)
}
return nil
}
// Emit dispatches an event to all matching hooks.
func (hm *HookManager) Emit(event HookEvent) {
if hm == nil {
return
}
event.Project = hm.project
if event.Timestamp.IsZero() {
event.Timestamp = time.Now()
}
hm.mu.RLock()View on GitHub (pinned to 4000b2338a)
Solutions
- Prefix the URL with https:// (or http:// for local/plain endpoints)
- Use http://127.0.0.1:PORT for local development endpoints
- If a non-HTTP sink is needed, implement it as a command-type hook instead
Example fix
// before (config.toml) url = "localhost:8080/hooks/agent" // after url = "http://localhost:8080/hooks/agent"
Defensive patterns
Strategy: validation
Validate before calling
for i, h := range hooks {
if h.Type == "http" && h.URL != "" &&
!strings.HasPrefix(h.URL, "http://") && !strings.HasPrefix(h.URL, "https://") {
return fmt.Errorf("hooks[%d]: url must start with http:// or https://", i)
}
} Try / catch
u, err := url.Parse(h.URL)
if err != nil || (u.Scheme != "http" && u.Scheme != "https") {
return fmt.Errorf("hook url must be absolute http(s): %q", h.URL)
} Prevention
- Always write full URLs including the scheme in hook configs
- Parse the URL with net/url when building configs programmatically
- Use http://127.0.0.1 explicitly for local endpoints instead of a bare host
- Lint hook URLs in CI
When it happens
Trigger: NewHookManager receives a hook with Type == "http" whose URL is non-empty but does not start with "http://" or "https://" — e.g. url = "example.com/hook" (missing scheme) or url = "file:///tmp/hook".
Common situations: Writing url = "localhost:8080/hook" without a scheme; pasting a bare domain; using a non-HTTP scheme expecting it to work; internal shorthand like "hook://...".
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
- invalid remote image URL
- event is required
- command is required for type=command
- url is required for type=http
- unknown handler type %q (must be command or http)
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/39501717dbce8fc3.
Report an issue: GitHub.