{"record":{"id":"cdcb21571fcdd587","repo":"siyuan-note/siyuan","slug":"marketplace-package-is-not-installed","errorCode":null,"errorMessage":"marketplace package is not installed","messagePattern":"marketplace package is not installed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":238,"sourceCode":"\t}\n\ttoken, err = bazaarRatingUserToken()\n\tif nil != err {\n\t\treturn \"\", err\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)\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","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/bazaar_rating.go#L220-L256","documentation":"Rating operations are restricted to packages actually installed in this workspace. validateBazaarPackageRatingRequest0 scans GetInstalledPackageInfos(pkgType) for a valid (InvalidReason == \"\") package whose Name equals packageName; if none is found, this error is returned without contacting the cloud.","triggerScenarios":"Calling GetBazaarPackageRating or SetBazaarPackageRating for a package name that is not currently installed, is installed but broken (non-empty InvalidReason), or is installed under a different pkgType than the one passed.","commonSituations":"Rating a package the user browsed in the marketplace but never installed; package was uninstalled while a rating UI was open; package failed to load (InvalidReason set) so it no longer counts as installed; passing \"themes\" while the package is installed as \"plugins\".","solutions":["Install the package first (or verify it appears in GetInstalledPackageInfos with an empty InvalidReason) before rating","Ensure the pkgType argument matches the type the package is installed as","Reload the installed-package list to refresh state after install/uninstall, then retry","Check info.Pkg.InvalidReason for the package; fix the underlying load failure so it counts as validly installed"],"exampleFix":"// before: rating an uninstalled package\ninfos, _, _, _ := model.GetInstalledPackageInfos(\"plugins\")\nif len(infos) == 0 { return errors.New(\"plugin not installed\") }\n// after: verify the exact package is validly installed\ninstalled := false\nfor _, info := range infos {\n    if info.Pkg.InvalidReason == \"\" && info.Pkg.Name == packageName { installed = true; break }\n}\nif !installed { return errors.New(\"install the package before rating it\") }","handlingStrategy":"validation","validationCode":"installed := false\nfor _, info := range installedInfos {\n    if info.Pkg.InvalidReason == \"\" && info.Pkg.Name == packageName { installed = true; break }\n}\nif !installed { return errors.New(\"install the package before rating it\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable rating UI actions for packages confirmed installed and valid (empty InvalidReason)","Refresh installed-package state after any install/uninstall before offering rating","Match pkgType to how the package is actually installed"],"tags":["marketplace","precondition","package-not-installed","rating"],"backgroundTag":"resource-not-found","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"}