{"record":{"id":"41e3c89bbb704cd5","repo":"siyuan-note/siyuan","slug":"localized-please-sign-in-message-conf-language-31","errorCode":null,"errorMessage":"localized please-sign-in message (Conf.Language(31))","messagePattern":"localized please-sign-in message \\(Conf\\.Language\\(31\\)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/bazaar_rating.go","lineNumber":254,"sourceCode":"\t}\n\tif !installed {\n\t\treturn \"\", errors.New(\"marketplace package is not installed\")\n\t}\n\n\texists, err := bazaar.HasBazaarPackage(ctx, pkgType, packageName)\n\tif nil != err {\n\t\treturn \"\", err\n\t}\n\tif !exists {\n\t\treturn \"\", errors.New(\"official marketplace package not found\")\n\t}\n\treturn token, nil\n}\n\nfunc getBazaarRatingUserToken() (string, error) {\n\tuser := Conf.GetUser()\n\tif nil == user || \"\" == user.UserToken {\n\t\treturn \"\", errors.New(Conf.Language(31))\n\t}\n\treturn user.UserToken, nil\n}\n\nfunc getInstalledOfficialBazaarPackageNames(ctx context.Context, pkgType string,\n\tpackageNames []string) ([]string, error) {\n\tif !isValidBazaarPackageType(pkgType) {\n\t\treturn nil, errors.New(\"invalid package type\")\n\t}\n\tinstalledInfos, _, _, err := bazaarRatingInstalledPackageInfos(pkgType)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tinstalled := make(map[string]bool, len(installedInfos))\n\tfor _, info := range installedInfos {\n\t\tif \"\" == info.Pkg.InvalidReason {\n\t\t\tinstalled[info.Pkg.Name] = true\n\t\t}","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/bazaar_rating.go#L236-L272","documentation":"getBazaarRatingUserToken requires a signed-in cloud account: if Conf.GetUser() returns nil or the user token is empty, it returns the localized 'please sign in' message (Conf.Language(31)). It is the gate for all cloud rating operations, since every rating API call must carry a user token.","triggerScenarios":"Calling GetBazaarPackageRating, SetBazaarPackageRating, or GetInstalledBazaarPackageUserRatings while no cloud account is configured, the user is logged out, or the stored token is empty; also returned by requestBazaarPackageRating on HTTP 401 when the token has been revoked.","commonSituations":"Fresh SiYuan installation with no SiYuan account; user signed out of cloud sync; expired/revoked token cleared after an auth failure; headless/API usage of rating endpoints without configuring an account.","solutions":["Sign in to a SiYuan account in the UI (Settings - Account) so Conf carries a non-empty UserToken, then retry","Catch this error in UI code and prompt the user to sign in (it is already user-localized via Conf.Language(31))","If the user is signed in but this still fires, the token may have been invalidated server-side (HTTP 401 path clears it) — re-authenticate"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"user := Conf.GetUser()\nsignedIn := user != nil && user.UserToken != \"\"","typeGuard":null,"tryCatchPattern":"_, _, _, err := model.SetBazaarPackageRating(ctx, pkgType, name, rating)\nif err != nil && err.Error() == Conf.Language(31) {\n    showDialog(\"请先登录云端账户\") // or match on the localized sign-in message\n    return\n}","preventionTips":["Check sign-in state before invoking any cloud rating API and route to the login flow","Handle HTTP 401 by re-authenticating; the token is cleared server-side invalidation","Do not call rating APIs from headless contexts without a configured account"],"tags":["authentication","cloud","sign-in","rating"],"backgroundTag":"authentication-required","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}