{"record":{"id":"79b866910c7edd96","repo":"siyuan-note/siyuan","slug":"conf-language-294","errorCode":null,"errorMessage":"Conf.Language(294)","messagePattern":"Conf\\.Language\\(294\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/cloud_service.go","lineNumber":745,"sourceCode":"\t\tlogging.LogErrorf(\"get community user failed: %s\", result[\"msg\"])\n\t\treturn nil, errRequestUserFailed\n\t}\n\n\tdataStr := result[\"data\"].(string)\n\tdata := util.AESDecrypt(dataStr)\n\tuser := &conf.User{}\n\tif err = gulu.JSON.UnmarshalJSON(data, &user); err != nil {\n\t\tlogging.LogErrorf(\"get community user failed: %s\", err)\n\t\treturn nil, errRequestUserFailed\n\t}\n\treturn user, nil\n}\n\nfunc UseActivationcode(code string) (err error) {\n\tcode = util.RemoveInvalid(code)\n\tcode = strings.TrimSpace(code)\n\tif \"\" == code {\n\t\treturn errors.New(Conf.Language(294))\n\t}\n\tuser := Conf.GetUser()\n\tif user == nil {\n\t\treturn errors.New(Conf.Language(31))\n\t}\n\tinvalidUser := cloudAccountAuthFailureHandler(user.UserToken)\n\trequestResult := gulu.Ret.NewResult()\n\trequest := httpclient.NewCloudRequest30s()\n\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 {","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/cloud_service.go#L727-L763","documentation":"UseActivationcode rejects an empty activation code string with the localized message Conf.Language(294) ('Activation code cannot be empty'). The kernel sanitizes the input with util.RemoveInvalid and strings.TrimSpace; if nothing remains, no cloud request is made and the localized empty-input error is returned immediately.","triggerScenarios":"Calling the API endpoint /api/account/useActivationcode (handler useActivationcode) with an empty or whitespace-only code, or a code consisting solely of characters stripped by util.RemoveInvalid.","commonSituations":"User clicks 'Use activation code' in the subscription dialog without pasting a code; clipboard contained only whitespace or invisible characters; frontend sent the field unvalidated.","solutions":["Enter a valid activation code in Settings - Account before submitting","Trim and validate the code client-side before calling the endpoint","If the clipboard paste appears non-empty but fails, check for whitespace-only or unsupported characters"],"exampleFix":"// before\nfetchPost('/api/account/useActivationcode', {code: ''})\n// after\nconst code = inputEl.value.trim();\nif (!code) { showMessage(window.siyuan.languages[294]); return; }\nfetchPost('/api/account/useActivationcode', {code})","handlingStrategy":"validation","validationCode":"const code = (input.value || '').trim();\nif (!code) { showMessage(window.siyuan.languages[294]); return; }","typeGuard":"function hasActivationCode(v: unknown): v is string {\n  return typeof v === \"string\" && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always trim and non-empty check activation-code input before calling the API","Disable the submit button until the code field is non-empty","Strip clipboard artifacts before pasting"],"tags":["validation","empty-input","localization","activation-code"],"backgroundTag":"empty-required-field","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"}