{"record":{"id":"d28c9902863a40f4","repo":"siyuan-note/siyuan","slug":"account-authentication-failed-please-login-again-d28c99","errorCode":null,"errorMessage":"Account authentication failed, please login again","messagePattern":"Account authentication failed, please login again","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":219,"sourceCode":"\t}\n\tif !bazaar.ApplyBazaarPackageRatingDistribution(region, packageName, distribution) {\n\t\treturn nil, false, 0, errors.New(\"invalid rating distribution returned by cloud server\")\n\t}\n\n\trating, ratingAvailable = bazaarRatingAfterUpdate(ctx, region, packageName, distribution)\n\treturn rating, ratingAvailable, data.Rating, nil\n}\n\nfunc validateBazaarPackageRatingRequest0(ctx context.Context, pkgType, packageName string) (token string, err error) {\n\tif !isValidBazaarPackageType(pkgType) {\n\t\treturn \"\", errors.New(\"invalid package type\")\n\t}\n\tif !bazaar.IsValidPackageName(packageName) {\n\t\treturn \"\", errors.New(\"invalid package name\")\n\t}\n\tuser := Conf.GetUser()\n\tif nil == user || \"\" == user.UserToken {\n\t\treturn \"\", errors.New(Conf.Language(31))\n\t}\n\n\tinstalledInfos, _, _, err := GetInstalledPackageInfos(pkgType)\n\tif nil != err {\n\t\treturn \"\", err\n\t}\n\tinstalled := false\n\tfor _, info := range installedInfos {\n\t\tif \"\" == info.Pkg.InvalidReason && packageName == info.Pkg.Name {\n\t\t\tinstalled = true\n\t\t\tbreak\n\t\t}\n\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)","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/bazaar_rating.go#L201-L237","documentation":"Conf.Language(31) resolves to 'Account authentication failed, please login again'. validateBazaarPackageRatingRequest0 throws it when Conf.GetUser() returns nil or the user has an empty UserToken, i.e. no SiYuan account is logged into this kernel. Rating marketplace packages requires an authenticated cloud account because the rating is stored server-side per user. Returned by both /api/bazaar/getBazaarPackageRating and /api/bazaar/setBazaarPackageRating.","triggerScenarios":"Calling either rating endpoint while the user is logged out; account data cleared from conf after a logout or workspace reset; calling the model functions from headless/kernel-mode runs where no account session exists.","commonSituations":"Fresh installs or new workspaces where nobody logged in; users who logged out in Settings - Account; automation scripts hitting the API on a kernel with no account; token removed by workspace switching.","solutions":["Log into a SiYuan account via Settings - Account, then retry","Verify login state first via /api/setting/getAccount before calling the rating API","For automation, skip rating calls when no account is configured instead of erroring"],"exampleFix":"// before\nrating, available, userRating, err := model.SetBazaarPackageRating(ctx, \"plugins\", \"my-plugin\", 5)\n\n// after: gate on login state first\nif user := model.Conf.GetUser(); nil == user || \"\" == user.UserToken {\n    return errors.New(\"login required before rating\")\n}\nrating, available, userRating, err := model.SetBazaarPackageRating(ctx, \"plugins\", \"my-plugin\", 5)","handlingStrategy":"validation","validationCode":"user := model.Conf.GetUser()\nif nil == user || \"\" == user.UserToken {\n    return errors.New(\"rating requires a logged-in SiYuan account\")\n}\n// safe to call model.Get/SetBazaarPackageRating now","typeGuard":"func hasRatingAccount() bool {\n    user := model.Conf.GetUser()\n    return nil != user && \"\" != user.UserToken\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"please login again\") {\n    // no local session: prompt login; do not retry until the user authenticates\n}","preventionTips":["Gate rating UI behind the account-login state","For headless/automation kernels, skip rating endpoints entirely","Re-check login state after workspace switches"],"tags":["siyuan","bazaar","rating","authentication","account"],"backgroundTag":"user-not-authenticated","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}