{"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":250,"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":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar_rating.go#L232-L268","documentation":"validateBazaarPackageRatingRequest0 requires the package to be currently installed locally and structurally valid (empty InvalidReason) before rating operations are allowed (kernel/model/bazaar_rating.go:242-250). It scans GetInstalledPackageInfos(pkgType) for a matching name and returns this error when no installed, valid package matches packageName.","triggerScenarios":"Calling GetBazaarPackageRating or SetBazaarPackageRating for a package that is not installed, was uninstalled, is installed under a different pkgType, or whose local install is flagged with a non-empty InvalidReason (broken/corrupt install).","commonSituations":"Rating a marketplace package by name from a script before installing it; the package was removed after the name was captured; pkgType/plugin mismatch (e.g. passing a theme name with pkgType=\"plugins\"); a broken install leaving InvalidReason set.","solutions":["Install the package via the marketplace before rating it","Verify pkgType matches the package's actual type (plugins vs themes vs icons etc.)","Use the exact name from the installed package metadata (info.Pkg.Name), which also guarantees an empty InvalidReason","If the package is installed but flagged, reinstall it to clear the InvalidReason and retry"],"exampleFix":"// before\ninfos, _, _, _ := model.GetInstalledPackageInfos(\"plugins\")\n_ = infos // rating attempted regardless\nmodel.SetBazaarPackageRating(ctx, \"plugins\", \"not-installed-plugin\", 5)\n// after\ninfos, _, _, _ := model.GetInstalledPackageInfos(\"plugins\")\nfor _, info := range infos {\n    if info.Pkg.Name == \"target-plugin\" && info.Pkg.InvalidReason == \"\" {\n        model.SetBazaarPackageRating(ctx, \"plugins\", \"target-plugin\", 5)\n    }\n}","handlingStrategy":"validation","validationCode":"infos, _, _, err := model.GetInstalledPackageInfos(pkgType)\nif err != nil { return err }\ninstalled := false\nfor _, info := range infos {\n    if info.Pkg.Name == packageName && info.Pkg.InvalidReason == \"\" { installed = true; break }\n}\nif !installed { return fmt.Errorf(\"package %s is not installed (or has an invalid install)\", packageName) }","typeGuard":null,"tryCatchPattern":"_, _, _, err := model.SetBazaarPackageRating(ctx, pkgType, name, rating)\nif err != nil && strings.Contains(err.Error(), \"marketplace package is not installed\") {\n    return fmt.Errorf(\"install %s (%s) before rating it\", name, pkgType)\n}","preventionTips":["Check installation state before rating: match name AND empty InvalidReason","Ensure pkgType corresponds to the package's actual marketplace type","Re-pull installed package infos rather than caching names across installs/uninstalls","Reinstall packages whose info.Pkg.InvalidReason is non-empty"],"tags":["go","marketplace","prerequisite","not-installed"],"backgroundTag":"resource-not-found","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"}