siyuan-note/siyuan · error

invalid bazaar package rating

Error message

invalid bazaar package rating: %s

What it means

If a package entry carries a rating, it is passed through normalizePackageRating, which returns a validity flag. An unnormalizable rating (wrong shape, out-of-range values) aborts parsing with the package name in the message. Ratings are optional per package but must be well-formed when present.

Solutions

  1. Fix the rating object shape/values for the named package in the index generator
  2. Omit the rating field entirely for that package if no valid data exists
  3. Re-fetch the index after upstream repair

Example fix

// before
{"packages":{"pkg":{"repo":"o/r","downloads":5,"rating":{"stars":"many"}}}}
// after
{"packages":{"pkg":{"repo":"o/r","downloads":5,"rating":{"stars":4.5,"count":100}}}}
Defensive patterns

Strategy: validation

Validate before calling

if (pkg.rating != null && !(typeof pkg.rating.stars === "number" && pkg.rating.stars >= 0 && pkg.rating.stars <= 5)) throw new Error("malformed rating")

Prevention

When it happens

Trigger: fetchBazaarIndexPath receives an index whose packages.<name>.rating has an unexpected shape (e.g. wrong field types, star counts out of range) so normalizePackageRating reports invalid.

Common situations: An index generator changed its rating schema; a hand-edited fixture has a malformed rating object; a partially upgraded server emits ratings in the old format.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/502975cd053f6224. Report an issue: GitHub.

Appendix: source

Thrown at kernel/bazaar/index.go:240

			ret.meta.RatingsAvailable = false
		} else {
			if !hasPackages {
				return nil, errors.New("incomplete bazaar index metadata")
			}
			if err = json.Unmarshal(packagesRaw, &ret.packages); nil != err {
				return nil, err
			}
			if nil == ret.packages {
				return nil, errors.New("invalid bazaar index packages")
			}
			for packageName, pkg := range ret.packages {
				if !IsValidPackageName(packageName) || nil == pkg || !isValidBazaarRepo(pkg.Repo) || 0 > pkg.Downloads {
					return nil, fmt.Errorf("invalid bazaar index package: %s", packageName)
				}
				if nil != pkg.Rating {
					rating, valid := normalizePackageRating(pkg.Rating)
					if !valid {
						return nil, fmt.Errorf("invalid bazaar package rating: %s", packageName)
					}
					pkg.Rating = rating
				}
			}
		}
	} else if hasPackages {
		return nil, errors.New("incomplete bazaar index metadata")
	}

	if !hasMeta || 2 == ret.meta.Schema || bazaarIndexSchema < ret.meta.Schema {
		for rawRepo, rawStats := range raw {
			if "meta" == rawRepo || "packages" == rawRepo {
				continue
			}
			repo, valid := normalizeLegacyBazaarRepo(rawRepo)
			if !valid {
				return nil, fmt.Errorf("invalid bazaar repository: %s", rawRepo)
			}

View on GitHub (pinned to 9f775e8a12)