{"record":{"id":"8419684abd10dbc0","repo":"siyuan-note/siyuan","slug":"conf-language-31-assets","errorCode":null,"errorMessage":"Conf.Language(31)","messagePattern":"Conf\\.Language\\(31\\)","errorType":"http","errorClass":null,"httpStatus":401,"severity":"error","filePath":"kernel/model/assets.go","lineNumber":1491,"sourceCode":"\t\t\tutil.PushUpdateMsg(msgId, msg, 3000)\n\t\t}\n\n\t\trequestResult := gulu.Ret.NewResult()\n\t\trequest := httpclient.NewCloudFileRequest2m()\n\t\tresp, reqErr := request.\n\t\t\tSetSuccessResult(requestResult).\n\t\t\tSetFile(\"file[]\", absAsset).\n\t\t\tSetCookies(&http.Cookie{Name: \"symphony\", Value: uploadToken}).\n\t\t\tSetHeader(\"meta-type\", metaType).\n\t\t\tSetHeader(\"biz-type\", bizType).\n\t\t\tPost(util.GetCloudServer() + \"/apis/siyuan/upload?ver=\" + util.Ver)\n\t\tif nil != reqErr {\n\t\t\tlogging.LogErrorf(\"upload assets failed: %s\", reqErr)\n\t\t\treturn count, ErrFailedToConnectCloudServer\n\t\t}\n\n\t\tif 401 == resp.StatusCode {\n\t\t\terr = errors.New(Conf.Language(31))\n\t\t\treturn\n\t\t}\n\n\t\tif 0 != requestResult.Code {\n\t\t\tlogging.LogErrorf(\"upload assets failed: %s\", requestResult.Msg)\n\t\t\terr = fmt.Errorf(Conf.Language(94), requestResult.Msg)\n\t\t\treturn\n\t\t}\n\n\t\tabsAsset = filepath.ToSlash(absAsset)\n\t\trelAsset := absAsset[strings.Index(absAsset, \"assets/\"):]\n\t\tcompletedUploadAssets = append(completedUploadAssets, relAsset)\n\t\tlogging.LogInfof(\"uploaded asset [%s]\", relAsset)\n\t\tcount++\n\t}\n\n\tif !ignorePushMsg {\n\t\tutil.PushClearMsg(msgId)","sourceCodeStart":1473,"sourceCodeEnd":1509,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/assets.go#L1473-L1509","documentation":"During cloud asset upload (uploadAssets2Cloud), an HTTP 401 response from the cloud server causes err = errors.New(Conf.Language(31)): \"Account authentication failed, please log in again in [Settings - Account & Sync - Account]\". The server rejected the request because the SiYuan account token/session is missing, expired, or invalid.","triggerScenarios":"Uploading assets to SiYuan cloud when the stored auth token is expired or revoked, the user never logged in, or the server responds 401 to the upload request (checked right after reqErr handling at the top of the response processing).","commonSituations":"Long-lived sessions where the cloud token expired; logging out on another device invalidating the session; clock skew invalidating tokens; using cloud sync features without an active paid/account session.","solutions":["Log in again via Settings - Account & Sync - Account to refresh the token","Log out and back in to force re-authentication if the token is stale","Check network/proxy setup so the auth endpoints are reachable and not stripping cookies/headers","Retry the upload after re-login; if 401 persists, verify the account subscription status on the cloud side"],"exampleFix":"// before\nresp, _ := http.Post(uploadURL, ...)\n// after (client-side guard)\nif !conf.IsLoggedIn() || conf.TokenExpired() {\n    return errors.New(\"please log in to SiYuan account before uploading assets\")\n}","handlingStrategy":"try-catch","validationCode":"if !conf.IsLoggedIn() {\n    return errors.New(\"log in via Settings - Account & Sync - Account before cloud upload\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"Account authentication failed\") {\n    promptRelogin()\n    return\n}","preventionTips":["Check login state before initiating cloud uploads","Re-authenticate after long sessions or device changes","Keep system clock synchronized to avoid token validation failures"],"tags":["go","cloud","authentication","upload"],"backgroundTag":"authentication-required","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}