vxcontrol/pentagi · error · FatalError

failed to create http client: %w

Error message

failed to create http client: %w

What it means

The firecrawl searcher's search step calls system.GetHTTPClient(f.cfg) to build its HTTP client; when that fails (invalid proxy config, TLS setup), it wraps the cause in a FatalError since retrying with the same config will not help.

Source

Thrown at backend/pkg/tools/searchers/firecrawl.go:137

			langfuse.WithEventMetadata(langfuse.Metadata{
				"engine":      "firecrawl",
				"query":       req.Query,
				"max_results": req.MaxResults,
				"error":       err.Error(),
			}),
		)

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

	return result, nil
}

func (f *firecrawl) search(ctx context.Context, query string, maxResults int) (string, error) {
	client, err := system.GetHTTPClient(f.cfg)
	if err != nil {
		return "", Fatal(fmt.Errorf("failed to create http client: %w", err))
	}

	// sources is intentionally omitted: /v2/search defaults to ["web"], which is
	// all this tool consumes, and it avoids the string-vs-object shape ambiguity
	// that field carries across the API/SDK layers.
	reqPayload := firecrawlRequest{
		Query: query,
		Limit: maxResults,
		ScrapeOptions: &firecrawlScrapeOptions{
			Formats:         []string{"markdown"},
			OnlyMainContent: true,
		},
	}
	reqBody, err := json.Marshal(reqPayload)
	if err != nil {
		return "", Fatal(fmt.Errorf("failed to marshal request body: %v", err))
	}

View on GitHub (pinned to ea665308ba)

Solutions

  1. Fix the proxy/TLS configuration referenced by f.cfg (env vars) and restart.
  2. Test the proxy URL is reachable: curl -x <proxy> https://firecrawl.dev.
  3. Remove the proxy setting if not required for this deployment.
  4. Check CA certificate mounting if TLS errors are the wrapped cause.

Example fix

// before: bad proxy
SEARCH_FIRECRAWL_PROXY=http://127.0.0.1:9999
// after
SEARCH_FIRECRAWL_PROXY=http://proxy.internal:3128  # reachable host
Defensive patterns

Strategy: validation

Validate before calling

if cfg.ProxyURL != "" {
  u, err := url.Parse(cfg.ProxyURL)
  if err != nil || u.Host == "" { return fmt.Errorf("invalid proxy url: %v", err) }
  if conn, err := net.DialTimeout("tcp", u.Host, 3*time.Second); err != nil { return err } else { conn.Close() }
}

Prevention

When it happens

Trigger: f.cfg contains an unreachable/malformed proxy URL or invalid TLS material, causing system.GetHTTPClient to return an error before any network call.

Common situations: Wrong PROXY_* env vars, self-signed CA not mounted, misconfigured HTTP_PROXY/HTTPS_PROXY for the container.

Related errors


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