{"record":{"id":"26aa4d1d870775ca","repo":"siyuan-note/siyuan","slug":"invalid-public-rating-returned-by-cloud-server","errorCode":null,"errorMessage":"invalid public rating returned by cloud server","messagePattern":"invalid public rating returned by cloud server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":180,"sourceCode":"\t}\n\n\tregion := util.CurrentCloudRegion\n\tdata := bazaarPackageSetRatingData{}\n\terr = requestBazaarPackageRating(ctx, \"/apis/siyuan/bazaar/setBazaarPackageRating\", map[string]any{\n\t\t\"token\":       token,\n\t\t\"packageName\": packageName,\n\t\t\"rating\":      userRating,\n\t}, &data)\n\tif nil != err {\n\t\treturn nil, false, 0, err\n\t}\n\tif data.Rating != userRating {\n\t\treturn nil, false, 0, errors.New(\"invalid user rating returned by cloud server\")\n\t}\n\tif nil != data.RatingAvailable {\n\t\tif !*data.RatingAvailable {\n\t\t\tif nil != data.PublicRating {\n\t\t\t\treturn nil, false, 0, errors.New(\"invalid public rating returned by cloud server\")\n\t\t\t}\n\t\t\tif 0 == len(data.Distribution) {\n\t\t\t\treturn nil, false, data.Rating, nil\n\t\t\t}\n\t\t} else {\n\t\t\tif nil == data.PublicRating {\n\t\t\t\tif 0 != data.Rating || !bazaar.ClearBazaarPackageRating(packageName) {\n\t\t\t\t\treturn nil, false, 0, errors.New(\"invalid public rating returned by cloud server\")\n\t\t\t\t}\n\t\t\t\trating, ratingAvailable = bazaar.GetCachedBazaarPackageRating(packageName)\n\t\t\t\tif !ratingAvailable || nil != rating {\n\t\t\t\t\treturn nil, false, 0, errors.New(\"invalid public rating returned by cloud server\")\n\t\t\t\t}\n\t\t\t\treturn nil, true, data.Rating, nil\n\t\t\t}\n\t\t\tif 0 < data.Rating && 1 > data.PublicRating.Distribution[data.Rating-1] {\n\t\t\t\treturn nil, false, 0, errors.New(\"invalid public rating returned by cloud server\")\n\t\t\t}","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar_rating.go#L162-L198","documentation":"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.","triggerScenarios":"Cloud returns data.ratingAvailable=false (or absent, treated as unavailable in the nil branch at line 208) together with a non-null data.publicRating.","commonSituations":"Cloud API schema drift (new semantics for ratingAvailable); region deployments with divergent response shapes; proxies injecting extra fields.","solutions":["Retry; if it persists, verify client/cloud version compatibility","Inspect the raw JSON response to confirm the inconsistent payload","Update to a kernel version matching the cloud API revision"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go\nif strings.Contains(err.Error(), \"invalid public rating returned by cloud server\") {\n    // retry once; on persistence, refresh the rating via GetBazaarPackageRating\n}","preventionTips":["Update to matching kernel/cloud API versions","Log the raw JSON body when the response fails consistency checks","Test against all cloud regions"],"tags":["cloud","validation","response"],"backgroundTag":"unexpected-api-response-shape","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"}