{"record":{"id":"b6822ef69aeef15a","repo":"siyuan-note/siyuan","slug":"result-msg-bazaar-rating","errorCode":null,"errorMessage":"result.Msg","messagePattern":"result\\.Msg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":394,"sourceCode":"\t\tinvalidUser()\n\t\treturn errors.New(Conf.Language(31))\n\t}\n\tif http.StatusTooManyRequests == resp.StatusCode {\n\t\treturn ErrBazaarRatingRateLimited\n\t}\n\tif http.StatusOK != resp.StatusCode {\n\t\tif body, readErr := resp.ToBytes(); nil == readErr {\n\t\t\t_ = json.Unmarshal(body, &errorResult)\n\t\t}\n\t\tif http.StatusServiceUnavailable == resp.StatusCode && \"bazaarPackagePending\" == errorResult.Data.ErrorCode {\n\t\t\treturn ErrBazaarPackagePending\n\t\t}\n\t\tlogging.LogWarnf(\"request bazaar package rating [%s] failed: HTTP %d\", body[\"packageName\"], resp.StatusCode)\n\t\treturn fmt.Errorf(\"request bazaar package rating failed: HTTP %d (%s)\", resp.StatusCode, http.StatusText(resp.StatusCode))\n\t}\n\tif 0 != result.Code {\n\t\tif \"\" != result.Msg {\n\t\t\treturn errors.New(result.Msg)\n\t\t}\n\t\treturn errors.New(\"request bazaar package rating failed\")\n\t}\n\t*data = result.Data\n\treturn nil\n}\n\nfunc isValidBazaarPackageType(pkgType string) bool {\n\tswitch pkgType {\n\tcase \"plugins\", \"widgets\", \"icons\", \"templates\", \"themes\":\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n","sourceCodeStart":376,"sourceCodeEnd":410,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar_rating.go#L376-L410","documentation":"The cloud API envelope carries a non-zero Code with a human-readable Msg on business failures; requestBazaarPackageRating surfaces result.Msg verbatim as the error. The text is produced server-side, not locally.","triggerScenarios":"Server-side validation or business-rule rejection during a rating request: e.g. rate/permission rules, package not found server-side, or invalid payload accepted by HTTP but rejected by the API logic.","commonSituations":"Submitting the same rating twice where the server forbids it; account restrictions; server version newer than the client sending unexpected fields.","solutions":["Read the returned message — it states the server-side cause directly","Update SiYuan to the latest version to match current server API expectations","If the message indicates permissions, verify the cloud account state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure client and payload match current server API expectations\nawait checkKernelVersionAtLeast(\"3.1\"); // server API may reject old clients","typeGuard":null,"tryCatchPattern":"try {\n  await api.setBazaarPackageRating(pkgType, pkg, rating);\n} catch (e) {\n  if (!isLocalValidationError(e) && e.serverMessage) {\n    showToast(e.serverMessage); // server-supplied result.Msg explains the cause\n  } else throw e;\n}","preventionTips":["Surface result.Msg text to users instead of swallowing it","Keep SiYuan updated to stay in sync with server business rules","Avoid duplicate submissions that server rules may reject"],"tags":["api","cloud","bazaar"],"backgroundTag":"api-error-response","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"}