{"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":436,"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":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/bazaar.go#L418-L454","documentation":"Thrown by GetInstalledPackageSize when, after enumerating installed packages of the given type, none has info.Pkg.Name equal to the requested packageName. The package is simply not installed under that type, so its size cannot be reported.","triggerScenarios":"Requesting the on-disk size of a plugin/theme/icon/template/widget that is not currently installed, or whose installed directory's manifest name does not match packageName (e.g. the directory was renamed).","commonSituations":"UI asking for a package size after it was uninstalled, or for a name that differs from the installed manifest name (directory vs. manifest mismatch). Also if the manifest failed to parse, the entry may carry the dir name rather than the declared name.","solutions":["Verify the package is installed (list installed packages first) before requesting its size.","Ensure packageName matches the manifest's name field, not just the directory name.","Handle not-found gracefully in the caller by checking the installed list membership."],"exampleFix":"// before\nsize, _, err := model.GetInstalledPackageSize(pkgType, name) // may be uninstalled\n// after\ninstalled := model.GetInstalledPackages(pkgType, frontend, \"\")\nfound := false\nfor _, p := range installed { if p.Name == name { found = true; break } }\nif !found { return /* not installed */ }","handlingStrategy":"validation","validationCode":"// Confirm the package is installed before requesting its size.\ninstalled := model.GetInstalledPackages(pkgType, frontend, \"\")\nfound := false\nfor _, p := range installed {\n    if p.Name == packageName {\n        found = true\n        break\n    }\n}\nif !found {\n    return // nothing to size\n}\nsize, hSize, err := model.GetInstalledPackageSize(pkgType, packageName)","typeGuard":null,"tryCatchPattern":"size, hSize, err := model.GetInstalledPackageSize(pkgType, packageName)\nif err != nil {\n    if err.Error() == \"installed package not found\" {\n        // package not installed or name mismatch; refresh installed list\n    }\n    return\n}","preventionTips":["Refresh the installed-package list before requesting a size for a name.","Ensure packageName matches the manifest name, not just the directory name.","Handle not-found gracefully rather than treating it as a hard failure."],"tags":["bazaar","package-management","not-found","state-check"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}