{"record":{"id":"1005e4353377e6a7","repo":"siyuan-note/siyuan","slug":"installed-package-not-found","errorCode":null,"errorMessage":"installed package not found","messagePattern":"installed package not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar.go","lineNumber":425,"sourceCode":"\t\t}\n\t}\n\treturn\n}\n\n// GetInstalledPackageSize 获取本地集市包的安装大小\nfunc GetInstalledPackageSize(pkgType, packageName string) (size int64, hSize string, err error) {\n\tinstalledInfos, basePath, _, err := GetInstalledPackageInfos(pkgType)\n\tif err != nil {\n\t\treturn\n\t}\n\tfor _, info := range installedInfos {\n\t\tif info.Pkg.Name != packageName {\n\t\t\tcontinue\n\t\t}\n\t\tinstallPath := filepath.Join(basePath, info.DirName)\n\t\treturn bazaar.GetInstalledPackageSize(pkgType, packageName, installPath)\n\t}\n\terr = errors.New(\"installed package not found\")\n\treturn\n}\n\n// GetBazaarPackageDetail 获取单个集市包的本地安装信息和在线信息。\n//\n// 在线集市不可用时仍返回本地信息，避免网络问题阻断已下载包详情。\nfunc GetBazaarPackageDetail(pkgType, packageName, frontend string) (installed, available *bazaar.Package) {\n\tfor _, pkg := range GetInstalledPackages(pkgType, frontend, \"\") {\n\t\tif pkg.InvalidReason != \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif pkg.Name == packageName {\n\t\t\tinstalled = pkg\n\t\t\tbreak\n\t\t}\n\t}\n\n\tavailablePackages, err := bazaar.GetBazaarPackagesMap(pkgType, frontend)","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar.go#L407-L443","documentation":"GetInstalledPackageSize scans all locally installed packages of the given pkgType and, when none has a package.json `name` matching packageName, returns this sentinel error. It means the package is not recognized as installed — its directory is missing, its package metadata failed to parse, or the name does not match. It is an internal lookup failure, not a size-calculation failure.","triggerScenarios":"Calling the kernel API that queries an installed package's size (GET /api/bazaar/getInstalledPackageSize style flows) with a pkgType/packageName that is not currently installed; the package directory was deleted manually; package.json in the package dir is missing/corrupt so info.Pkg.Name never matches; or a typo in the package name.","commonSituations":"Stale frontend state after manually deleting a theme/icon/plugin folder from the workspace; querying a package by marketplace name while the installed copy declares a different name in its package.json; calling before the first install ever happened.","solutions":["Verify the package exists under the workspace dir for its type (themes/, icons/, plugins/, widgets/, templates/) with a valid package.json whose name matches","Check for typos in packageName and that pkgType is correct","Reinstall the package from the marketplace, then query its size","If the folder exists but is corrupt, delete it and reinstall"],"exampleFix":"// before: querying size for a package assumed installed\nsize, _, err := model.GetInstalledPackageSize(\"plugins\", \"my-plugin\")\n// after: guard with the installed list first\nif !isPackageInstalled(\"plugins\", \"my-plugin\") { return errors.New(\"package not installed\") }\nsize, _, err := model.GetInstalledPackageSize(\"plugins\", \"my-plugin\")","handlingStrategy":"try-catch","validationCode":"func isPackageInstalled(pkgType, name string) bool {\n  pkgs := model.GetInstalledPackages(pkgType, \"\", \"\")\n  for _, p := range pkgs { if p.Name == name && p.InvalidReason == \"\" { return true } }\n  return false\n}","typeGuard":"if info == nil || info.Pkg == nil || info.Pkg.Name != wantName { return false }","tryCatchPattern":"size, _, err := model.GetInstalledPackageSize(pkgType, name)\nif err != nil {\n  if strings.Contains(err.Error(), \"installed package not found\") { /* treat as absent, size 0 */ }\n  return err\n}","preventionTips":["Resolve package names from GetInstalledPackages output rather than cached UI state","Treat package.json parse failures as 'not installed' in your mental model","Handle manual deletion of package folders gracefully"],"tags":["marketplace","package-management","not-found"],"backgroundTag":"record-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"}