{"record":{"id":"781796b7e95f5a4c","repo":"siyuan-note/siyuan","slug":"bazaar-rating-rate-limited","errorCode":null,"errorMessage":"bazaar rating rate limited","messagePattern":"bazaar rating rate limited","errorType":"exception","errorClass":"ErrBazaarRatingRateLimited","httpStatus":null,"severity":"warning","filePath":"kernel/model/bazaar_rating.go","lineNumber":68,"sourceCode":"type bazaarRatingCloudResult[T any] struct {\n\tCode int    `json:\"code\"`\n\tMsg  string `json:\"msg\"`\n\tData T      `json:\"data\"`\n}\n\ntype bazaarPackageUserRatingData struct {\n\tRating int `json:\"rating\"`\n}\n\ntype bazaarPackageSetRatingData struct {\n\tRating          int                   `json:\"rating\"`\n\tRatingAvailable *bool                 `json:\"ratingAvailable\"`\n\tPublicRating    *bazaar.PackageRating `json:\"publicRating\"`\n\tDistribution    []int64               `json:\"distribution\"`\n}\n\n// ErrBazaarRatingRateLimited 表示评分请求受到云端频率限制。\nvar ErrBazaarRatingRateLimited = errors.New(\"bazaar rating rate limited\")\n\n// ErrBazaarPackagePending 表示云端尚未同步包信息。\nvar ErrBazaarPackagePending = errors.New(\"bazaar package information has not synced yet\")\n\n// GetInstalledBazaarPackageRatings 获取指定已安装包的公开评分。\nfunc GetInstalledBazaarPackageRatings(ctx context.Context, pkgType string,\n\tpackageNames []string) (ratings map[string]*bazaar.PackageRating, eligiblePackageNames []string, err error) {\n\teligiblePackageNames, err = getInstalledOfficialBazaarPackageNames(ctx, pkgType, packageNames)\n\tif nil != err {\n\t\treturn nil, nil, err\n\t}\n\tif 0 == len(eligiblePackageNames) {\n\t\treturn map[string]*bazaar.PackageRating{}, []string{}, nil\n\t}\n\tratings, available := bazaarRatingPublicPackageRatings(ctx, eligiblePackageNames)\n\tif !available {\n\t\treturn nil, nil, errors.New(\"marketplace package ratings are unavailable\")\n\t}","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar_rating.go#L50-L86","documentation":"ErrBazaarRatingRateLimited is the sentinel error returned when the cloud rating service rejects a rating request because the client exceeded its frequency limit. The API layer maps it via errors.Is to the structured code 'bazaarRatingRateLimited' (apicontract.BazaarRatingError) instead of a generic failure, so clients can show a rate-limit message and back off.","triggerScenarios":"Requesting or setting a marketplace package rating (requestBazaarPackageRating / setBazaarPackageRatingError paths) after the user already submitted ratings recently; automated scripts polling rating endpoints in a loop; multiple devices sharing one cloud account ID hitting the same quota.","commonSituations":"A user toggling star ratings back and forth rapidly in the marketplace panel; CI or tooling iterating packages and fetching ratings for each; retry storms after transient network errors without backoff.","solutions":["Back off and retry the rating request after a delay (minutes, not seconds)","Check errors.Is(err, model.ErrBazaarRatingRateLimited) and map it to the bazaarRatingRateLimited API code rather than a generic error","Cache the rating response client-side instead of re-requesting per render","Stop scripted polling loops against the rating endpoints"],"exampleFix":"// before: generic handling loses the rate-limit signal\nif err := model.RequestBazaarPackageRating(ctx, pkgType, pkgName); err != nil { return err }\n// after: recognize rate limiting\nif err := model.RequestBazaarPackageRating(ctx, pkgType, pkgName); err != nil {\n    if errors.Is(err, model.ErrBazaarRatingRateLimited) {\n        return backoffAndRetry(err, 5*time.Minute)\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// throttle client-side: at most one rating request per minute\nif time.Since(lastRatingRequest) < time.Minute { return ErrBackoff }","typeGuard":"var rateLimited bool = errors.Is(err, model.ErrBazaarRatingRateLimited)","tryCatchPattern":"err := requestBazaarPackageRating(ctx, pkgType, name)\nif errors.Is(err, model.ErrBazaarRatingRateLimited) {\n  return retryAfter(err, 5*time.Minute) // exponential backoff\n}","preventionTips":["Cache rating responses instead of re-fetching per render","Apply exponential backoff on all rating endpoints","Avoid scripted loops hitting rating APIs; batch with delays","Map the sentinel to bazaarRatingRateLimited so clients can react specifically"],"tags":["marketplace","rating","rate-limit","cloud"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}