siyuan-note/siyuan · error
request failed: %s
Error message
request failed: %s
What it means
Returned by HTTPRequest when sendByMethod returns a non-nil error — i.e. the underlying req/v3 HTTP client failed to send or receive (DNS done by SSRF precheck already passed; this is transport-level). The original error text is appended for diagnostics. A nil response is handled separately (errorIndex 'nil response' neighbour).
Source
Thrown at kernel/util/httprequest.go:88
return 0, "", "", serr
}
method = strings.ToUpper(strings.TrimSpace(method))
if method == "" {
method = "GET"
}
request := httpclient.NewBrowserRequest()
for k, v := range headers {
request.SetHeader(k, v)
}
if body != "" && method != "GET" && method != "HEAD" {
request.SetBody(body)
}
resp, err := sendByMethod(request, method, rawURL)
if err != nil {
return 0, "", "", errors.New("request failed: " + err.Error())
}
if resp == nil {
return 0, "", "", errors.New("nil response")
}
defer resp.Body.Close()
statusCode = resp.StatusCode
contentType = resp.Header.Get("Content-Type")
maxReadBytes := int64(maxHTTPRequestBytes)
if !isTextContentType(contentType) {
maxReadBytes = maxHTTPRequestFileBytes
}
// ContentLength 为 -1(chunked)时跳过大小预检,交由 LimitReader 兜底截断。
if resp.ContentLength > maxReadBytes {
return statusCode, contentType, "", errors.New("response too large")
}
View on GitHub (pinned to 251596fc0d)
Solutions
- Inspect the appended transport error — 'connection refused' means the port is closed, 'TLS' means a certificate issue, 'i/o timeout' means reachability.
- Retry once for transient transport failures (reset, timeout); do not retry for TLS errors.
- If a proxy is required, confirm httpclient is configured with the proxy env (HTTP_PROXY/HTTPS_PROXY).
Example fix
// before
_, _, _, err := util.HTTPRequest("GET", rawURL, nil, "")
// after
var lastErr error
for attempt := 0; attempt < 2; attempt++ {
_, _, _, lastErr = util.HTTPRequest("GET", rawURL, nil, "")
if lastErr == nil || isTLSNetError(lastErr) {
break
}
time.Sleep(500 * time.Millisecond)
} Defensive patterns
Strategy: retry
Try / catch
var err error
for attempt := 0; attempt < 2; attempt++ {
_, _, _, err = util.HTTPRequest(method, rawURL, headers, body)
if err == nil || !isTransientTransport(err) { break }
time.Sleep(500 * time.Millisecond)
} Prevention
- Distinguish TLS errors (do not retry) from reset/timeout (retry once).
- Confirm proxy configuration (HTTP_PROXY/HTTPS_PROXY) when connectivity is fine but requests fail.
When it happens
Trigger: After passing URL/scheme/host/SSRF checks, the actual httpclient.NewBrowserRequest().Get/Post/... call fails: connection refused, TLS handshake error, dial timeout, broken connection mid-request, or proxy failure.
Common situations: The server is down or refusing connections; a TLS certificate is invalid or expired; a corporate proxy is unreachable; the network dropped mid-request; a firewall reset the connection.
Related errors
- read body failed: %s
- fetch failed: %s
- download custom emoji failed with status %d
- get stage index failed
- OAuth token endpoint returned %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/c9e52c765ca489d7.
Report an issue: GitHub.