siyuan-note/siyuan · error

Conf.Language(31) (localized: not logged in / login expired)

Error message

Conf.Language(31) (localized: not logged in / login expired)

What it means

CloudChatGPT (kernel/model/cloud_service.go:77) returns errors.New(Conf.Language(31)) — the localized 'not logged in / login expired' message — when the cloud AI endpoint responds HTTP 401. It also calls invalidUser(), which clears the cached account, so the next cloud call will see no user. This is an auth-state error, not a network error.

Solutions

  1. Log in again (Settings - Account) to refresh the cloud token, then retry the AI chat
  2. After catching this error, note that invalidUser() already cleared the cached user; re-fetch the account instead of retrying with the old token
  3. Check subscription status if the account is valid but the plan no longer covers AI features
  4. In code, detect the localized message or better check user == nil before calling CloudChatGPT and prompt login first

Example fix

// before
reply, stop, err := model.CloudChatGPT(msg, ctx)

// after
if model.Conf.GetUser() == nil {
    ui.promptLogin() // localized Conf.Language(31) equivalent
    return
}
reply, stop, err := model.CloudChatGPT(msg, ctx)
if err != nil && model.Conf.GetUser() == nil { // invalidUser() fired -> 401 path
    ui.promptLogin()
}
Defensive patterns

Strategy: validation

Validate before calling

if model.Conf.GetUser() == nil {
    ui.promptLogin() // localized Conf.Language(31)
    return
}

Type guard

user := model.Conf.GetUser()
if user == nil || user.UserToken == "" { promptLogin(); return }

Try / catch

if err != nil && model.Conf.GetUser() == nil { // 401 path cleared the user
    promptLoginThen(func() { retryChat() })
}

Prevention

When it happens

Trigger: Invoking AI chat while the cloud session token is expired or revoked (HTTP 401 from the ChatGPT proxy endpoint); token invalidated by logging in elsewhere or cloud-side session expiry.

Common situations: Long-lived desktop session whose token aged out; using AI features after the subscription/account became invalid; multiple devices causing token rotation.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/e90010657eb56d7b. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/cloud_service.go:77

		"content": msg,
	})
	payload["messages"] = messages

	requestResult := gulu.Ret.NewResult()
	request := httpclient.NewCloudRequest30s()
	resp, err := request.
		SetSuccessResult(requestResult).
		SetCookies(&http.Cookie{Name: "symphony", Value: user.UserToken}).
		SetBody(payload).
		Post(util.GetCloudServer() + "/apis/siyuan/ai/chatGPT")
	if err != nil {
		logging.LogErrorf("chat gpt failed: %s", err)
		err = ErrFailedToConnectCloudServer
		return
	}
	if http.StatusUnauthorized == resp.StatusCode {
		invalidUser()
		return "", true, errors.New(Conf.Language(31))
	}
	if http.StatusOK != resp.StatusCode {
		return "", true, ErrFailedToConnectCloudServer
	}
	if 0 != requestResult.Code {
		err = errors.New(requestResult.Msg)
		stop = true
		return
	}

	data := requestResult.Data.(map[string]any)
	choices := data["choices"].([]any)
	if 1 > len(choices) {
		stop = true
		return
	}
	choice := choices[0].(map[string]any)
	message := choice["message"].(map[string]any)

View on GitHub (pinned to 9f775e8a12)