vxcontrol/pentagi · error · Fatal
failed to create http client: %w
Error message
failed to create http client: %w
What it means
traversaal.search obtains an *http.Client via system.GetHTTPClient(t.cfg) and wraps any failure in a Fatal error 'failed to create http client: %w'. This fires when the shared HTTP client factory cannot build a client from the searcher config — typically invalid proxy URL or bad TLS settings in configuration.
Source
Thrown at backend/pkg/tools/searchers/traversaal.go:74
langfuse.WithEventLevel(langfuse.ObservationLevelWarning),
langfuse.WithEventMetadata(langfuse.Metadata{
"engine": "traversaal",
"query": req.Query,
"error": err.Error(),
}),
)
obs.LogErrorOrCancel(logger, err, "failed to search in traversaal")
return "", err
}
return result, nil
}
func (t *traversaal) search(ctx context.Context, query string) (string, error) {
client, err := system.GetHTTPClient(t.cfg)
if err != nil {
return "", Fatal(fmt.Errorf("failed to create http client: %w", err))
}
reqBody, err := json.Marshal(struct {
Query string `json:"query"`
}{
Query: query,
})
if err != nil {
return "", Fatal(fmt.Errorf("failed to marshal request body: %v", err))
}
req, err := http.NewRequest(http.MethodPost, traversaalURL, bytes.NewBuffer(reqBody))
if err != nil {
return "", Fatal(fmt.Errorf("failed to build request: %v", err))
}
req = req.WithContext(ctx)
req.Header.Set("Content-Type", "application/json")View on GitHub (pinned to ea665308ba)
Solutions
- Read the wrapped error — GetHTTPClient reports whether the proxy URL or TLS config is at fault.
- Fix proxy environment variables (HTTP_PROXY/HTTPS_PROXY/NO_PROXY) to be valid URLs.
- Verify any custom CA certificate paths/content in the searchers config.
- Write a startup health check that constructs the HTTP client once so bad config fails fast at boot, not mid-search.
Example fix
// before: silently continuing with nil-ish config
cfg := config.Load()
// after: validate proxy/TLS up front
if _, err := system.GetHTTPClient(cfg); err != nil {
log.Fatalf("invalid HTTP client config: %v", err)
} Defensive patterns
Strategy: validation
Validate before calling
if _, err := system.GetHTTPClient(cfg); err != nil {
log.Fatalf("invalid HTTP client configuration: %v", err)
} Try / catch
result, err := traversaalSearcher.Handle(ctx, req)
var f *searchers.FatalError
if errors.As(err, &f) && strings.Contains(f.Error(), "failed to create http client") {
return "", fmt.Errorf("fix proxy/TLS config for traversaal: %w", err)
} Prevention
- Validate HTTP_PROXY/HTTPS_PROXY values are parseable URLs at boot
- Verify custom CA certificate files exist and are readable before deployment
- Construct HTTP clients once at startup so config errors surface immediately
When it happens
Trigger: traversaal.Handle -> search() calls system.GetHTTPClient(t.cfg), which returns err (e.g. unparseable proxy URL, invalid TLS material), producing Fatal(fmt.Errorf("failed to create http client: %w", err)).
Common situations: Malformed HTTP_PROXY/HTTPS_PROXY env values; bad custom CA cert file path in config; incorrect cfg passed to the searcher at construction; TLS scheme typos.
Related errors
- failed to create http client: %w
- failed to build request: %v
- failed to create http client: %w
- failed to create http client: %w
- failed to do request: %v
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/66d9cb2bfce3ebec.
Report an issue: GitHub.