{"record":{"id":"870a05bb90c76238","repo":"siyuan-note/siyuan","slug":"account-authentication-failed-please-login-again-870a05","errorCode":null,"errorMessage":"Account authentication failed, please login again","messagePattern":"Account authentication failed, please login again","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/cloud_service.go","lineNumber":104,"sourceCode":"\tmessage := choice[\"message\"].(map[string]any)\n\tret = message[\"content\"].(string)\n\n\tif nil != choice[\"finish_reason\"] {\n\t\tfinishReason := choice[\"finish_reason\"].(string)\n\t\tif \"length\" == finishReason {\n\t\t\tstop = false\n\t\t} else {\n\t\t\tstop = true\n\t\t}\n\t} else {\n\t\tstop = true\n\t}\n\treturn\n}\n\nfunc StartFreeTrial() (err error) {\n\tif nil == Conf.GetUser() {\n\t\treturn errors.New(Conf.Language(31))\n\t}\n\n\trequestResult := gulu.Ret.NewResult()\n\trequest := httpclient.NewCloudRequest30s()\n\tresp, err := request.\n\t\tSetSuccessResult(requestResult).\n\t\tSetCookies(&http.Cookie{Name: \"symphony\", Value: Conf.GetUser().UserToken}).\n\t\tPost(util.GetCloudServer() + \"/apis/siyuan/user/startFreeTrial\")\n\tif err != nil {\n\t\tlogging.LogErrorf(\"start free trial failed: %s\", err)\n\t\treturn ErrFailedToConnectCloudServer\n\t}\n\tif http.StatusOK != resp.StatusCode {\n\t\tlogging.LogErrorf(\"start free trial failed: %d\", resp.StatusCode)\n\t\treturn ErrFailedToConnectCloudServer\n\t}\n\tif -2 == requestResult.Code { // 已经试用订阅过\n\t\treturn errors.New(Conf.Language(298))","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/cloud_service.go#L86-L122","documentation":"In StartFreeTrial, returned immediately when Conf.GetUser() returns nil, i.e. no user is currently logged in. Conf.Language(31) resolves to 'Account authentication failed, please login again'. This is a precondition guard before any network call, so it fires before the request is even built.","triggerScenarios":"The StartFreeTrial API is invoked while the local account state has no authenticated user (user never logged in, logged out, or session was cleared). Because Conf.GetUser() is nil, the function returns before constructing the HTTP request.","commonSituations":"User opened the trial dialog without signing in; a previous logout cleared Conf user state; fresh install with no account; the user account object failed to load from configuration.","solutions":["Prompt the user to sign in before exposing the 'start free trial' action.","Guard the UI: disable the trial button when no user is logged in.","After login, reload Conf so Conf.GetUser() returns a valid user before retrying."],"exampleFix":"// before\nerr := StartFreeTrial()\n\n// after\nif Conf.GetUser() == nil {\n    promptLogin()\n    return\n}\nerr := StartFreeTrial()","handlingStrategy":"validation","validationCode":"// Guard the trial action on an authenticated user\nif model.Conf.GetUser() == nil {\n    promptLogin()\n    return\n}","typeGuard":"func isUserLoggedIn() bool { return model.Conf.GetUser() != nil }","tryCatchPattern":"if err := model.StartFreeTrial(); err != nil {\n    if isAuthError(err) { routeToLogin() } else { showError(err) }\n}","preventionTips":["Disable the 'start free trial' control until the user is signed in.","Check Conf.GetUser() before any subscription-related cloud call.","Refresh login state on app start to avoid stale nil user."],"tags":["cloud","authentication","subscription","precondition","cloud-service"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}