Tencent/WeKnora · error
failed to execute Zhipu request: %w
Error message
failed to execute Zhipu request: %w
What it means
The Zhipu web search provider returns this error when the outbound HTTP request to the Zhipu search API fails at the transport level. The provider wraps the underlying *url.Error from http.Client.Do with %w so callers can use errors.Is/As to inspect the root cause. It means the request never completed — no HTTP status was received.
Source
Thrown at internal/infrastructure/web_search/zhipu.go:145
Count: maxResults,
ContentSize: p.contentSize,
}
body, err := json.Marshal(requestBody)
if err != nil {
return nil, fmt.Errorf("failed to marshal Zhipu request: %w", err)
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, p.baseURL, bytes.NewReader(body))
if err != nil {
return nil, fmt.Errorf("failed to create Zhipu request: %w", err)
}
req.Header.Set("Authorization", "Bearer "+p.apiKey)
req.Header.Set("Content-Type", "application/json")
logger.Infof(ctx, "[WebSearch][Zhipu] query=%q maxResults=%d engine=%s", preparedQuery, maxResults, p.searchEngine)
resp, err := p.client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to execute Zhipu request: %w", err)
}
defer resp.Body.Close()
respBody, err := readZhipuResponseBody(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, zhipuHTTPError(resp.StatusCode, respBody)
}
var response zhipuSearchResponse
if err := json.Unmarshal(respBody, &response); err != nil {
return nil, fmt.Errorf("failed to unmarshal Zhipu response: %w", err)
}
if response.Error.Message != "" || response.Error.Code != "" {
return nil, fmt.Errorf("Zhipu API error (%s): %s", response.Error.Code, response.Error.Message)
}View on GitHub (pinned to 988cbb0330)
Solutions
- Retry the request with backoff — transport errors are often transient
- Verify network/DNS connectivity to the Zhipu API host (curl -v the endpoint URL)
- Check the configured timeout and whether the caller's context was cancelled or expired early
- Inspect proxy environment variables (HTTP_PROXY/HTTPS_PROXY) that the default HTTP client honors
Example fix
// before
results, err := provider.Search(ctx, query) // panics on err==nil assumption
// after
results, err := provider.Search(ctx, query)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
// retry with backoff
}
return fmt.Errorf("web search failed: %w", err)
} Defensive patterns
Strategy: retry
Validate before calling
if p.apiKey == "" { return errors.New("zhipu api key not configured") }
// also confirm context is alive: if ctx.Err() != nil { return ctx.Err() } Type guard
func isTransportError(err error) bool { var ne net.Error; return errors.As(err, &ne) } Try / catch
results, err := provider.Search(ctx, q)
if err != nil {
var ne net.Error
if errors.As(err, &ne) && ne.Timeout() { return retryWithBackoff(ctx, q) }
return err
} Prevention
- Set sane client timeouts and retry transport errors with exponential backoff
- Monitor egress connectivity to the Zupu host from your deployment environment
- Check proxy env vars in containerized deployments
- Always pass a live (non-expired) context
When it happens
Trigger: Calling provider.Search() when the Zhipu endpoint is unreachable: DNS resolution failure, connection refused/timeout, TLS handshake failure, or a cancelled request context.
Common situations: No internet access or a firewall blocking api.zhipu.ai; an invalid proxy setting on the HTTP client; the request context timing out or being cancelled mid-flight; transient network blips in a container orchestrator.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- failed to execute request: %w
- keenable API returned status %d: %s
- failed to read response: %w
- failed to execute Metaso request: %w
- failed to read Zhipu response: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/4b654e8f9326eb38.
Report an issue: GitHub.