{"record":{"id":"cb39b4a327947d23","repo":"siyuan-note/siyuan","slug":"requestresult-msg","errorCode":null,"errorMessage":"requestResult.Msg","messagePattern":"requestResult\\.Msg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/cloud_service.go","lineNumber":772,"sourceCode":"\tresp, err := request.\n\t\tSetSuccessResult(requestResult).\n\t\tSetBody(map[string]string{\"data\": code}).\n\t\tSetCookies(&http.Cookie{Name: \"symphony\", Value: user.UserToken}).\n\t\tPost(util.GetCloudServer() + \"/apis/siyuan/useActivationcode\")\n\tif err != nil {\n\t\tlogging.LogErrorf(\"check activation code 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.StatusOK != resp.StatusCode {\n\t\tlogging.LogErrorf(\"check activation code failed: %d\", resp.StatusCode)\n\t\treturn ErrFailedToConnectCloudServer\n\t}\n\tif 0 != requestResult.Code {\n\t\treturn errors.New(requestResult.Msg)\n\t}\n\treturn\n}\n\nfunc CheckActivationcode(code string) (retCode int, msg string) {\n\tcode = util.RemoveInvalid(code)\n\tcode = strings.TrimSpace(code)\n\tif \"\" == code {\n\t\tretCode = 1\n\t\tmsg = Conf.Language(294)\n\t\treturn\n\t}\n\tretCode = 1\n\tuser := Conf.GetUser()\n\tif user == nil {\n\t\treturn retCode, Conf.Language(31)\n\t}\n\tinvalidUser := cloudAccountAuthFailureHandler(user.UserToken)","sourceCodeStart":754,"sourceCodeEnd":790,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/cloud_service.go#L754-L790","documentation":"This is the cloud server's application-level error message (requestResult.Msg) passed through verbatim. When the useActivationcode endpoint responds HTTP 200 but with a non-zero result Code, the kernel surfaces the server-provided message describing why the activation code was rejected.","triggerScenarios":"Calling model.UseActivationcode(code) where the cloud responds 200 but requestResult.Code != 0 (kernel/model/cloud_service.go:772) — the code is invalid, already redeemed, expired, belongs to another account type, or the account already has an active subscription.","commonSituations":"Redeeming a code that was already used on this or another account; typo in the code; code expired per vendor terms; trying to redeem a subscription code on an account that already has an active subscription.","solutions":["Read the returned message — it states the server's specific rejection reason (invalid code, already used, etc.)","Double-check the activation code for typos or truncation when copying","If the code was already redeemed, use the account it was applied to or contact SiYuan support with the code and order details","Check the account's subscription status on ld246.com to confirm whether redemption already took effect"],"exampleFix":"// caller-side surfacing of the server message\nconst res = await fetchSyncPost(\"/api/attr/useActivationcode\", {code});\nif (res.msg && res.code !== 0) { showMessage(res.msg, 6000); return; } // show e.g. \"activation code already used\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"const res = await fetchSyncPost(\"/api/attr/useActivationcode\", {code});\nif (res.code !== 0) {\n  // res.msg is the cloud server's reason (invalid/already-used/expired code)\n  showMessage(res.msg || \"Activation failed\", 6000);\n  return;\n}\nshowMessage(\"Activation successful\");","preventionTips":["Copy activation codes exactly, without truncation or extra characters","Check redemption status on the marketplace before retrying an already-used code","Surface the server message to the user instead of showing a generic failure"],"tags":["activation-code","upstream-server","api-error","cloud"],"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"}