{"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":"error_code","errorClass":"ErrBazaarRatingRateLimited","httpStatus":null,"severity":"warning","filePath":"kernel/model/bazaar_rating.go","lineNumber":67,"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// 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}\n\treturn ratings, eligiblePackageNames, nil\n}\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/bazaar_rating.go#L49-L85","documentation":"ErrBazaarRatingRateLimited is a sentinel error (errors.New) declared in bazaar_rating.go indicating the cloud rating service rejected the request due to frequency limits. The API layer detects it with errors.Is and attaches errorCode 'bazaarRatingRateLimited' to the response so clients can show a rate-limit notice instead of a generic failure.","triggerScenarios":"Calling setBazaarPackageRating / requestBazaarPackageRating (via kernel/api/bazaar.go rating endpoints) too frequently; the cloud backend returns a rate-limit signal and the kernel maps it to this sentinel error.","commonSituations":"UI auto-retrying rating submissions; scripted clients hammering the rating endpoint; multiple rating actions issued in quick succession from several windows/devices on the same account.","solutions":["Back off and retry after a delay; do not retry immediately in a loop.","Respect the errorCode 'bazaarRatingRateLimited' in API responses and surface a cooldown message to users.","Batch or debounce rating actions in the client instead of sending per-keystroke requests.","Check the cloud service status if the limit appears to persist abnormally long."],"exampleFix":"// before: immediate retry loop\nfor { err := model.SetBazaarPackageRating(ctx, pkg, stars); if err == nil { break } }\n// after: back off on the sentinel\nif errors.Is(err, model.ErrBazaarRatingRateLimited) {\n    time.Sleep(30 * time.Second)\n    continue\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"// Go: detect the sentinel\nisRateLimited := errors.Is(err, model.ErrBazaarRatingRateLimited)","tryCatchPattern":"if errors.Is(err, model.ErrBazaarRatingRateLimited) {\n    time.Sleep(backoff)\n    return retry()\n}","preventionTips":["Debounce rating submissions in the UI","Never retry rating requests in a tight loop","Respect the bazaarRatingRateLimited errorCode in API responses"],"tags":["go","marketplace","rating","rate-limit","cloud"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}