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

  1. Pass the exact package identifier as listed in the marketplace (e.g. the repo name), not the display title
  2. Trim whitespace and verify the name is non-empty and contains no '/' or special characters before calling
  3. Pre-validate with bazaar.IsValidPackageName(name) to fail fast with a clearer message
  4. 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

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


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)