siyuan-note/siyuan · error
invalid package name
Error message
invalid package name
What it means
validateBazaarPackageRatingRequest0 rejects package names that fail bazaar.IsValidPackageName before any cloud request (kernel/model/bazaar_rating.go:230-231). A valid marketplace package name is a sanitized identifier (repo-style name); empty strings, names with path separators, whitespace, or control characters are rejected.
Solutions
- Pass the exact package identifier as listed in the marketplace (e.g. the repo name), not the display title
- Trim whitespace and verify the name is non-empty and contains no '/' or special characters before calling
- Pre-validate with bazaar.IsValidPackageName(name) to fail fast with a clearer message
- Use the package name from installed package metadata (info.Pkg.Name) rather than user input
Example fix
// before
model.SetBazaarPackageRating(ctx, "plugins", "My Cool Plugin/1.0", 5)
// after
name := "siyuan-plugin-foo"
if !bazaar.IsValidPackageName(name) { return errors.New("bad package name") }
model.SetBazaarPackageRating(ctx, "plugins", name, 5) Defensive patterns
Strategy: validation
Validate before calling
func validPkgName(name string) bool { return name != "" && bazaar.IsValidPackageName(name) } Try / catch
if !bazaar.IsValidPackageName(packageName) {
return fmt.Errorf("package name %q is not a valid marketplace identifier", packageName)
} Prevention
- Pass the marketplace identifier (repo-style name), never the display title
- Strip version suffixes and author prefixes not part of the canonical name
- Read the name from installed package metadata (info.Pkg.Name) instead of free-text input
- Pre-validate with bazaar.IsValidPackageName before any cloud rating call
When it happens
Trigger: Calling GetBazaarPackageRating or SetBazaarPackageRating with packageName = "", a name containing '/' or whitespace, a display name instead of the package identifier, or a name carrying a version suffix.
Common situations: Passing the human-readable package title rather than its repo name; including the author prefix inconsistently; trimming/validation missing on a user-supplied input in a plugin or script; path traversal attempts.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- marketplace package manifest must be at the archive root or…
- all asset mappings failed
- assetPath is not an image referenced by the document
- assetPath is required for analyze
- at least one asset path or mapping is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/d8484293d2877d68.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/bazaar_rating.go:231
}
distribution := [5]int64(data.Distribution)
if 0 < data.Rating && 1 > distribution[data.Rating-1] {
return nil, false, 0, errors.New("invalid rating distribution returned by cloud server")
}
if !bazaar.ApplyBazaarPackageRatingDistribution(region, packageName, distribution) {
return nil, false, 0, errors.New("invalid rating distribution returned by cloud server")
}
rating, ratingAvailable = bazaarRatingAfterUpdate(ctx, region, packageName, distribution)
return rating, ratingAvailable, data.Rating, nil
}
func validateBazaarPackageRatingRequest0(ctx context.Context, pkgType, packageName string) (token string, err error) {
if !isValidBazaarPackageType(pkgType) {
return "", errors.New("invalid package type")
}
if !bazaar.IsValidPackageName(packageName) {
return "", errors.New("invalid package name")
}
token, err = bazaarRatingUserToken()
if nil != err {
return "", err
}
installedInfos, _, _, err := GetInstalledPackageInfos(pkgType)
if nil != err {
return "", err
}
installed := false
for _, info := range installedInfos {
if "" == info.Pkg.InvalidReason && packageName == info.Pkg.Name {
installed = true
break
}
}
if !installed {View on GitHub (pinned to 9f775e8a12)