siyuan-note/siyuan · error

invalid bazaar package rating: %s

Error message

invalid bazaar package rating: %s

What it means

A package entry in the index may include a rating object, which must pass normalizePackageRating (expected shape/ranges for the rating fields). An entry whose rating cannot be normalized aborts the parse for the whole index, with the package name in the message.

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 8641553a1f)

Solutions

  1. Fix the offending package's rating data on the bazaar server so it matches the expected rating shape, or omit the rating field for it
  2. Compare the publisher's rating serialization against normalizePackageRating's expectations and align the format
  3. Check for a publisher/client version mismatch after a ratings-format change and roll back or upgrade accordingly
  4. Retry after the index is republished with corrected data

Example fix

// index entry, before
"my-plugin": {"repo": "owner/my-plugin", "rating": {"count": "many"}}
// after
"my-plugin": {"repo": "owner/my-plugin", "rating": {"count": 42}}
Defensive patterns

Strategy: validation

Validate before calling

// validate rating shape before publishing
if pkg.Rating != nil {
    if _, valid := normalizePackageRating(pkg.Rating); !valid {
        return fmt.Errorf("bad rating for %s", name)
    }
}

Try / catch

if err != nil && strings.Contains(err.Error(), "invalid bazaar package rating") {
    // rating schema drift for that package; serve cached snapshot and fix publisher
}

Prevention

When it happens

Trigger: parseBazaarIndex finds pkg.Rating non-nil for some package but normalizePackageRating returns valid=false — e.g. rating fields of the wrong type, out-of-range counts, or a malformed rating object published for that package.

Common situations: A stats aggregation bug on the bazaar server emitting a rating with unexpected field types; schema drift between publisher and the rating shape this client version understands; corrupted cached data used to build the index.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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