siyuan-note/siyuan · error
invalid package type
Error message
invalid package type
What it means
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.
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
Example fix
// before
installBazaarPackage("Plugin", name, repoURL, hash) // rejected
// after
installBazaarPackage("plugins", name, repoURL, hash) Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = ["plugins","themes","icons","templates","widgets"];
if (!SUPPORTED.includes(pkgType)) throw new Error("invalid package type: " + pkgType); Prevention
- 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
When it happens
Trigger: Calling installBazaarPackage, InstallLocalBazaarPackage, or UpdateBazaarPackage with pkgType not in the supported set (typo such as 'plugin', or a new marketplace category not yet supported).
Common situations: 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').
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid package name
- invalid package name
- invalid package type
- marketplace package manifest must be at the archive root or…
- official marketplace package not found
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/088b46869b54c755.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/bazaar.go:75
if !isValidPackageName(packageName) {
return "", "", errors.New("invalid package name")
}
var baseDir, jsonFileName string
switch pkgType {
case "plugins":
baseDir, jsonFileName = filepath.Join(util.DataDir, "plugins"), "plugin.json"
case "themes":
baseDir, jsonFileName = util.ThemesPath, "theme.json"
case "icons":
baseDir, jsonFileName = util.IconsPath, "icon.json"
case "templates":
baseDir, jsonFileName = filepath.Join(util.DataDir, "templates"), "template.json"
case "widgets":
baseDir, jsonFileName = filepath.Join(util.DataDir, "widgets"), "widget.json"
default:
logging.LogErrorf("invalid package type: %s", pkgType)
return "", "", errors.New("invalid package type")
}
installPath := filepath.Join(baseDir, packageName)
if !gulu.File.IsSubPath(baseDir, installPath) {
return "", "", errors.New("invalid package name")
}
return installPath, jsonFileName, nil
}
// installMeta 记录安装前后的状态,供安装后处理使用
type installMeta struct {
update bool
}
// batchInstallItem 同类型批量安装时单个包的结果
type batchInstallItem struct {
name string
meta installMetaView on GitHub (pinned to 9f775e8a12)