siyuan-note/siyuan · error

invalid public rating returned by cloud server

Error message

invalid public rating returned by cloud server

What it means

When the cloud responds that rating is not available (ratingAvailable=false), SetBazaarPackageRating expects no publicRating payload. If the cloud nevertheless includes a publicRating object, the response is internally inconsistent and rejected.

Solutions

  1. Retry; if it persists, verify client/cloud version compatibility
  2. Inspect the raw JSON response to confirm the inconsistent payload
  3. Update to a kernel version matching the cloud API revision
Defensive patterns

Strategy: retry

Try / catch

// Go
if strings.Contains(err.Error(), "invalid public rating returned by cloud server") {
    // retry once; on persistence, refresh the rating via GetBazaarPackageRating
}

Prevention

When it happens

Trigger: Cloud returns data.ratingAvailable=false (or absent, treated as unavailable in the nil branch at line 208) together with a non-null data.publicRating.

Common situations: Cloud API schema drift (new semantics for ratingAvailable); region deployments with divergent response shapes; proxies injecting extra fields.

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@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/26aa4d1d870775ca. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/bazaar_rating.go:180

	}

	region := util.CurrentCloudRegion
	data := bazaarPackageSetRatingData{}
	err = requestBazaarPackageRating(ctx, "/apis/siyuan/bazaar/setBazaarPackageRating", map[string]any{
		"token":       token,
		"packageName": packageName,
		"rating":      userRating,
	}, &data)
	if nil != err {
		return nil, false, 0, err
	}
	if data.Rating != userRating {
		return nil, false, 0, errors.New("invalid user rating returned by cloud server")
	}
	if nil != data.RatingAvailable {
		if !*data.RatingAvailable {
			if nil != data.PublicRating {
				return nil, false, 0, errors.New("invalid public rating returned by cloud server")
			}
			if 0 == len(data.Distribution) {
				return nil, false, data.Rating, nil
			}
		} else {
			if nil == data.PublicRating {
				if 0 != data.Rating || !bazaar.ClearBazaarPackageRating(packageName) {
					return nil, false, 0, errors.New("invalid public rating returned by cloud server")
				}
				rating, ratingAvailable = bazaar.GetCachedBazaarPackageRating(packageName)
				if !ratingAvailable || nil != rating {
					return nil, false, 0, errors.New("invalid public rating returned by cloud server")
				}
				return nil, true, data.Rating, nil
			}
			if 0 < data.Rating && 1 > data.PublicRating.Distribution[data.Rating-1] {
				return nil, false, 0, errors.New("invalid public rating returned by cloud server")
			}

View on GitHub (pinned to 9f775e8a12)