{"record":{"id":"0ba64f0bf2c84883","repo":"siyuan-note/siyuan","slug":"cloud-server-result-message-result-msg","errorCode":null,"errorMessage":"cloud server result message (result.Msg)","messagePattern":"cloud server result message \\(result\\.Msg\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":362,"sourceCode":"\t\tPost(bazaarRatingCloudServer() + endpoint)\n\tif nil != err {\n\t\tlogging.LogWarnf(\"request bazaar package rating failed: %s\", err)\n\t\treturn ErrFailedToConnectCloudServer\n\t}\n\tif http.StatusUnauthorized == resp.StatusCode {\n\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\tlogging.LogWarnf(\"request bazaar package rating failed: %d\", resp.StatusCode)\n\t\treturn ErrFailedToConnectCloudServer\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":344,"sourceCodeEnd":378,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/bazaar_rating.go#L344-L378","documentation":"After an HTTP 200 response, requestBazaarPackageRating checks the cloud JSON envelope: if result.Code is non-zero, the cloud server itself rejected the request and the library surfaces result.Msg verbatim as the error. This is a pass-through of a server-side business error, not a transport failure.","triggerScenarios":"Calling GetBazaarPackageRating or SetBazaarPackageRating when the cloud API returns {code != 0, msg: \"...\"} — e.g. package not found on the marketplace, account not allowed to rate, or payload rejected by the server.","commonSituations":"Rating a package name/version that no longer exists in the marketplace, submitting a rating that violates server rules (e.g. own package, already rated under changed rules), or transient cloud-side validation changes.","solutions":["Read result.Msg (the returned error text) — it is the authoritative server explanation; act on it directly","Verify the package type/name/ID sent matches an existing marketplace package","Re-check authentication and request payload against the current cloud API contract","If the message is unclear, retry later or check bazaar server status; the failure is server-side"],"exampleFix":"// before\nif err := SetBazaarPackageRating(pkg, score); err != nil {\n    return err\n}\n// after\nif err := SetBazaarPackageRating(pkg, score); err != nil {\n    return fmt.Errorf(\"bazaar server rejected rating: %s\", err) // server result.Msg\n}","handlingStrategy":"try-catch","validationCode":"// ensure inputs reference real marketplace packages\nconst known = await bazaarPackageExists(pkgType, pkgName);\nif (!known) throw new Error(`unknown package ${pkgName}`);","typeGuard":null,"tryCatchPattern":"try {\n  await api.setBazaarPackageRating(pkg, score);\n} catch (e) {\n  showServerError(e.message); // server result.Msg surfaced verbatim\n}","preventionTips":["Display server messages to users instead of swallowing them","Validate package type/name against the current marketplace listing first","Keep the kernel updated so the cloud API contract stays in sync"],"tags":["cloud","api","bazaar","server-error"],"backgroundTag":"api-error-response","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"}