Tencent/WeKnora · error
Zhipu response exceeds %d bytes
Error message
Zhipu response exceeds %d bytes
What it means
The provider caps Zhipu response bodies at maxZhipuResponseBytes; it reads one extra byte via io.LimitReader and rejects any body exceeding the cap. This protects against unbounded memory consumption from a misbehaving or hostile endpoint.
Source
Thrown at internal/infrastructure/web_search/zhipu.go:223
time.RFC3339Nano,
"2006-01-02 15:04:05",
"2006-01-02 15:04",
"2006-01-02",
} {
if parsed, err := time.Parse(layout, value); err == nil {
return parsed, true
}
}
return time.Time{}, false
}
func readZhipuResponseBody(reader io.Reader) ([]byte, error) {
body, err := io.ReadAll(io.LimitReader(reader, maxZhipuResponseBytes+1))
if err != nil {
return nil, fmt.Errorf("failed to read Zhipu response: %w", err)
}
if len(body) > maxZhipuResponseBytes {
return nil, fmt.Errorf("Zhipu response exceeds %d bytes", maxZhipuResponseBytes)
}
return body, nil
}
func zhipuHTTPError(statusCode int, body []byte) error {
var response zhipuSearchResponse
if err := json.Unmarshal(body, &response); err == nil && (response.Error.Code != "" || response.Error.Message != "") {
return fmt.Errorf("Zhipu API returned status %d (%s): %s", statusCode, response.Error.Code, response.Error.Message)
}
detail := strings.TrimSpace(string(body))
if len(detail) > 4096 {
detail = detail[:4096]
}
if detail == "" {
return fmt.Errorf("Zhipu API returned status %d", statusCode)
}
return fmt.Errorf("Zhipu API returned status %d: %s", statusCode, detail)
}View on GitHub (pinned to 988cbb0330)
Solutions
- Reduce maxResults / narrow the query so the response stays under the cap
- Raise maxZhipuResponseBytes if legitimate payloads exceed it
- Verify no proxy is inflating responses with extra content
- Handle the error explicitly instead of treating it as transient
Example fix
// before results, err := provider.Search(ctx, bigQuery) // huge result set // after ctx = context.WithValue(ctx, key, opts) results, err := provider.Search(ctx, query, WithMaxResults(10)) // keep payload small
Defensive patterns
Strategy: validation
Validate before calling
if maxResults > 50 { return errors.New("reduce maxResults to stay under zhipu response byte cap") } Type guard
func isSizeLimitError(err error) bool { return strings.Contains(err.Error(), "response exceeds") } Try / catch
results, err := provider.Search(ctx, q)
if err != nil && strings.Contains(err.Error(), "response exceeds") {
return provider.Search(ctx, q, WithMaxResults(maxResults/2))
} Prevention
- Keep maxResults modest so payloads stay under the byte cap
- Do not blindly raise the cap — it exists to bound memory
- Check for proxies appending/bloating response bodies
- Handle size-limit errors distinctly from transient errors
When it happens
Trigger: Calling Search() when Zhipu (or an intercepting proxy) returns a response body larger than maxZhipuResponseBytes.
Common situations: A proxy returning a huge error page; extremely large search result sets; a misconfigured endpoint echoing oversized payloads.
Related errors
- invalid Zhipu search engine: %s
- invalid Zhipu content size: %s
- query is empty
- failed to marshal Zhipu request: %w
- failed to execute Zhipu request: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/633798e6eea259bd.
Report an issue: GitHub.