siyuan-note/siyuan · error
request user failed
Error message
request user failed
What it means
"request user failed" (errRequestUserFailed) is returned by the SiYuan kernel's cloud-account layer when the logged-in user cannot be resolved consistently. It is thrown when the user's token expiry time cannot be parsed during a cloud user refresh, or when the configured user changed while a refresh was in flight (concurrent account switch detected). It deliberately masks the underlying detail so callers get a stable, well-known sentinel error.
Solutions
- Log out and log back in to the SiYuan cloud account (Settings - Account) so the cached user record and token expiry time are rebuilt
- Retry the refresh after a moment — if it was a concurrent account-switch race, the second attempt will see a stable user
- Upgrade SiYuan to the latest version; older kernels may fail to parse a new expiry-time format returned by the cloud server
- If it persists, back up and reset the workspace's account info (conf.json user section) to clear the corrupted user record
Example fix
// concurrent refresh race in caller code
user, err := model.RefreshUser(token)
if errors.Is(err, model.ErrRequestUserFailed) { // retry once after account lock settles
time.Sleep(500 * time.Millisecond)
user, err = model.RefreshUser(token)
} Defensive patterns
Strategy: retry
Validate before calling
// ensure a user exists and token parses before refresh
const u = window.siyuan?.user;
if (!u || !u.UserToken) return;
if (isNaN(Date.parse(u.UserTokenExpireTime))) console.warn("token expire time unparseable, refresh may fail"); Try / catch
try {
const res = await fetchSyncPost("/api/user/refreshUser", {token});
if (res.code !== 0) throw new Error(res.msg);
} catch (e) {
// errRequestUserFailed: retry once, then prompt re-login
await new Promise(r => setTimeout(r, 500));
// second attempt, then surface "please log in again"
} Prevention
- Avoid concurrent account refreshes; serialize account operations in plugin/UI code
- Keep SiYuan and the cloud account session fresh so expiry-time formats stay compatible
- Detect this sentinel and fall back to a full re-login flow rather than retrying indefinitely
When it happens
Trigger: Calling model.RefreshUser(token) or getUser(token) when the cloud API returns a user whose UserTokenExpireTime fails strconv/time parsing (cloud_service.go:421), or when Conf.GetUser() differs from previousUser after acquiring cloudAccountMu (cloud_service.go:441), i.e. another goroutine switched accounts mid-refresh. Also surfaced by TestResolveCloudUserRefresh.
Common situations: The SiYuan cloud server changes its token-expiry-time format after an upgrade; multiple concurrent requests refresh the same account while the user logs in/out or switches accounts in another window; a corrupted cached user record in conf produces an unparseable expiry time.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- access to private/internal IP is prohibited
- agent runtime turn changed
- agent session revision conflict
- attribute view order changed; retry the drag
- attribute view rows changed; retry the drag
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/08552e9322cd05a9.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/cloud_service.go:700
desc = videoRegexp.ReplaceAllString(desc, " 视频 ")
desc = fileRegexp.ReplaceAllString(desc, " 文件 ")
desc = strings.ReplaceAll(desc, "\n\n", "")
desc = strings.TrimSpace(desc)
shorthand["shorthandDesc"] = desc
md := shorthand["shorthandContent"].(string)
shorthand["shorthandMd"] = md
tree := parse.Parse("", []byte(md), luteEngine.ParseOptions)
luteEngine.RenderOptions.ProtyleMarkNetImg = false
content := luteEngine.ProtylePreview(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)
shorthand["shorthandContent"] = content
}
return
}
var (
errInvalidUser = errors.New("invalid user")
errRequestUserFailed = errors.New("request user failed")
)
func getUser(token string) (*conf.User, error) {
result := map[string]any{}
request := httpclient.NewCloudRequest30s().SetRetryCount(0)
resp, err := request.
SetSuccessResult(&result).
SetBody(map[string]string{"token": token}).
Post(util.GetCloudServer() + "/apis/siyuan/user")
if err != nil {
logging.LogErrorf("get community user failed: %s", err)
return nil, errRequestUserFailed
}
if http.StatusOK != resp.StatusCode {
logging.LogErrorf("get community user failed: %d", resp.StatusCode)
if http.StatusUnauthorized == resp.StatusCode {
return nil, errInvalidUser
}View on GitHub (pinned to 9f775e8a12)