{"record":{"id":"088b46869b54c755","repo":"siyuan-note/siyuan","slug":"invalid-package-type","errorCode":null,"errorMessage":"invalid package type","messagePattern":"invalid package type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar.go","lineNumber":75,"sourceCode":"\tif !isValidPackageName(packageName) {\n\t\treturn \"\", \"\", errors.New(\"invalid package name\")\n\t}\n\n\tvar baseDir, jsonFileName string\n\tswitch pkgType {\n\tcase \"plugins\":\n\t\tbaseDir, jsonFileName = filepath.Join(util.DataDir, \"plugins\"), \"plugin.json\"\n\tcase \"themes\":\n\t\tbaseDir, jsonFileName = util.ThemesPath, \"theme.json\"\n\tcase \"icons\":\n\t\tbaseDir, jsonFileName = util.IconsPath, \"icon.json\"\n\tcase \"templates\":\n\t\tbaseDir, jsonFileName = filepath.Join(util.DataDir, \"templates\"), \"template.json\"\n\tcase \"widgets\":\n\t\tbaseDir, jsonFileName = filepath.Join(util.DataDir, \"widgets\"), \"widget.json\"\n\tdefault:\n\t\tlogging.LogErrorf(\"invalid package type: %s\", pkgType)\n\t\treturn \"\", \"\", errors.New(\"invalid package type\")\n\t}\n\n\tinstallPath := filepath.Join(baseDir, packageName)\n\tif !gulu.File.IsSubPath(baseDir, installPath) {\n\t\treturn \"\", \"\", errors.New(\"invalid package name\")\n\t}\n\treturn installPath, jsonFileName, nil\n}\n\n// installMeta 记录安装前后的状态，供安装后处理使用\ntype installMeta struct {\n\tupdate bool\n}\n\n// batchInstallItem 同类型批量安装时单个包的结果\ntype batchInstallItem struct {\n\tname string\n\tmeta installMeta","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar.go#L57-L93","documentation":"getPackageInstallPath only recognizes the pkgType values \"plugins\", \"themes\", \"icons\", \"templates\", and \"widgets\"; anything else falls to the default branch, logs 'invalid package type', and returns this error. The package type determines both the install base directory and the metadata JSON file name, so an unknown type cannot be resolved safely.","triggerScenarios":"Calling installBazaarPackage, InstallLocalBazaarPackage, or UpdateBazaarPackage with pkgType not in the supported set (typo such as 'plugin', or a new marketplace category not yet supported).","commonSituations":"Typo'd package type in scripts or plugins calling the install API; a new marketplace package category introduced upstream before the kernel added a case for it; case-sensitivity mistakes ('Plugins' instead of 'plugins').","solutions":["Use an exactly supported pkgType: \"plugins\", \"themes\", \"icons\", \"templates\", or \"widgets\" (lowercase)","If you need a new category, add a case to the switch in getPackageInstallPath mapping it to a base directory and metadata file","Check for case or pluralization typos before retrying"],"exampleFix":"// before\ninstallBazaarPackage(\"Plugin\", name, repoURL, hash) // rejected\n// after\ninstallBazaarPackage(\"plugins\", name, repoURL, hash)","handlingStrategy":"validation","validationCode":"const SUPPORTED = [\"plugins\",\"themes\",\"icons\",\"templates\",\"widgets\"];\nif (!SUPPORTED.includes(pkgType)) throw new Error(\"invalid package type: \" + pkgType);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize package-type constants in one shared list and reuse it","Keep types lowercase and exact; avoid ad-hoc strings at call sites","When adding a marketplace category, update both the caller and the kernel switch together"],"tags":["marketplace","invalid-enum","validation"],"backgroundTag":"invalid-enum-value","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"}