siyuan-note/siyuan · error
parse [t] failed: %s
Error message
parse [t] failed: %s
What it means
Returned by parseForwardProxyParams (network.go:391) when the optional `t` (timeout) query parameter is present but cannot be parsed by time.ParseDuration. The value must be a Go duration string (e.g. '30s', '2m', '1500ms', '1h30m'); an unparseable value yields this error and the request is rejected with HTTP 400 before the proxy client dials.
Source
Thrown at kernel/api/network.go:391
}
var record map[string][]string
if jsonErr := json.Unmarshal(hBytes, &record); jsonErr != nil {
err = fmt.Errorf("parse [h] failed: %s", jsonErr.Error())
return
}
for k, vs := range record {
for _, v := range vs {
h.Add(k, v)
}
}
}
timeout = 30 * time.Second
tParam := c.Query("t")
if tParam != "" {
if t, parseErr := time.ParseDuration(tParam); parseErr != nil {
err = fmt.Errorf("parse [t] failed: %s", parseErr.Error())
return
} else {
timeout = t
}
}
return
}
// forwardResponseHeaders copies src headers into dst with a "Siyuan-Proxy-" prefix on each key.
func forwardResponseHeaders(dst http.Header, src http.Header) {
for k, vs := range src {
for _, v := range vs {
dst.Add("Siyuan-Proxy-"+k, v)
}
}
}
View on GitHub (pinned to 251596fc0d)
Solutions
- Send `t` as a Go duration string with an explicit unit: '30s', '2m', '500ms'.
- If you only have a number of seconds, append 's': String(seconds) + 's'.
- If you do not need a custom timeout, omit `t` to use the 30s default.
Example fix
// before
fetch(`/api/network/forwardProxy?u=${u}&t=30`)
// after
fetch(`/api/network/forwardProxy?u=${u}&t=30s`) Defensive patterns
Strategy: validation
Validate before calling
// Convert a seconds number to a Go duration string, or omit for default
const t = seconds ? `${seconds}s` : undefined;
const q = new URLSearchParams({ u }); if (t) q.set('t', t); Prevention
- Always include a time unit ('s','ms','m') in `t`.
- Omit `t` to use the 30s default rather than guessing.
- Add a test asserting time.ParseDuration accepts your emitted value.
When it happens
Trigger: Sending ?t=30000 (a bare integer, not a duration), ?t=30 (intended seconds but missing unit), ?t=30sec (wrong unit suffix), or ?t=NaN. time.ParseDuration at network.go:390 fails and the error is wrapped at line 391. Note the default when `t` is omitted is 30s (line 387).
Common situations: Caller passes milliseconds as a plain number assuming seconds. Caller uses JS-style '30s' correctly but accidentally sends '30' from a numeric input. Locale/formatting inserted a decimal separator or unit typo. The docstring says 'nanoseconds' but the parser expects Go duration syntax.
Related errors
- missing query param [u]
- decode [u] failed: %s
- parse [u] failed: %s
- decode [h] failed: %s
- parse [h] failed: %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/e00ef312ad47f267.
Report an issue: GitHub.