{"record":{"id":"88056fd916078df2","repo":"siyuan-note/siyuan","slug":"conf-language-31-bazaar-rating","errorCode":null,"errorMessage":"Conf.Language(31)","messagePattern":"Conf\\.Language\\(31\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":266,"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":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar_rating.go#L248-L284","documentation":"getBazaarRatingUserToken returns the logged-in user's cloud token; if no user is signed in or the token is empty, it fails with localized message Conf.Language(31) (\"please log in to the cloud\"). Ratings APIs require an authenticated SiYuan account.","triggerScenarios":"Calling any bazaar rating API (GetBazaarPackageRating, SetBazaarPackageRating, installed ratings, or validateBazaarPackageRatingRequest's token path) while the workspace has no cloud account configured or user.UserToken is empty (not logged in, or login token expired/cleared).","commonSituations":"Self-hosted or offline instances never signed into SiYuan cloud; token invalidated after password change; automated tests running without cloud login.","solutions":["Log in to SiYuan cloud in Settings - Account so Conf.GetUser().UserToken is populated","If the token was invalidated, sign out and sign in again to refresh it","For headless/test environments, skip or mock the rating APIs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const user = await api.getUser(); // or check Conf user state\nif (!user || !user.userToken) {\n  throw new Error(\"Cloud login required before using marketplace rating APIs\");\n}","typeGuard":"function isLoggedIn(u) {\n  return typeof u === \"object\" && u !== null && typeof u.userToken === \"string\" && u.userToken.length > 0;\n}","tryCatchPattern":"try {\n  await api.getBazaarPackageRating(pkgType, packageName);\n} catch (e) {\n  if (isLoginRequiredError(e)) {\n    openAccountSettings(); // prompt cloud login\n  } else throw e;\n}","preventionTips":["Sign in to SiYuan cloud before using rating features","Handle token expiry by re-authenticating instead of retrying blindly","Skip rating calls in offline/headless environments"],"tags":["auth","cloud","bazaar"],"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"}