vxcontrol/pentagi · error · FatalError

failed to create http client: %w

Error message

failed to create http client: %w

What it means

The Perplexity searcher builds its HTTP client via `system.GetHTTPClient(p.cfg)`. If that helper fails (typically invalid proxy configuration — malformed URL, unsupported scheme, bad TLS material), the error is wrapped as a Fatal typed error at backend/pkg/tools/searchers/perplexity.go:139 before any request is sent.

Source

Thrown at backend/pkg/tools/searchers/perplexity.go:139

				"engine": "perplexity",
				"query":  req.Query,
				"model":  p.model(),
				"error":  err.Error(),
			}),
		)

		obs.LogErrorOrCancel(logger, err, "failed to search in perplexity")
		return "", err
	}

	return result, nil
}

// search performs a request to Perplexity API
func (p *perplexity) search(ctx context.Context, query string) (string, error) {
	client, err := system.GetHTTPClient(p.cfg)
	if err != nil {
		return "", Fatal(fmt.Errorf("failed to create http client: %w", err))
	}

	client.Timeout = p.timeout()

	// Creating message for the request
	messages := []Message{
		{
			Role:    "user",
			Content: query,
		},
	}

	// Forming the request
	reqPayload := CompletionRequest{
		Messages:               messages,
		Model:                  p.model(),
		SearchContextSize:      p.contextSize(),
		MaxTokens:              p.maxTokens(),

View on GitHub (pinned to ea665308ba)

Solutions

  1. Check the wrapped cause — GetHTTPClient's error names the bad setting (proxy URL or CA file)
  2. Fix the proxy env var / config value (valid absolute URL, reachable host) and restart the backend
  3. Remove the proxy setting entirely if no proxy is required to reach api.perplexity.ai
  4. If using a custom CA, verify the file exists inside the container and is valid PEM

Example fix

// before
HTTPS_PROXY="http://proxy host:3128" // invalid: space in host
// after
HTTPS_PROXY="http://proxy-host:3128"
Defensive patterns

Strategy: validation

Validate before calling

// validate proxy config before starting the engine
if proxy := os.Getenv("HTTPS_PROXY"); proxy != "" {
    if _, err := url.Parse(proxy); err != nil || strings.ContainsAny(proxy, " \t") {
        return fmt.Errorf("invalid HTTPS_PROXY: %q", proxy)
    }
}

Try / catch

_, err := engine.Handle(ctx, req)
if err != nil && searchers.IsFatal(err) && strings.Contains(err.Error(), "failed to create http client") {
    // config problem: fix proxy/TLS settings, do not retry
}

Prevention

When it happens

Trigger: `Handle` → `search` is invoked while `p.cfg` carries an unparseable proxy/TLS setting that `system.GetHTTPClient` rejects — e.g. PERPLEXITY (or global) proxy env var set to `http://[bad` or an unreadable CA file path.

Common situations: Malformed HTTP_PROXY/HTTPS_PROXY values; self-signed CA bundle path wrong in container; proxy scheme typo (socks5 unsupported by builder); config parsed from .env with stray whitespace/quotes.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/e3d2428ab86ad81f. Report an issue: GitHub.