{"record":{"id":"79b866910c7edd96","repo":"siyuan-note/siyuan","slug":"conf-language-294","errorCode":null,"errorMessage":"Conf.Language(294)","messagePattern":"Conf\\.Language\\(294\\)","errorType":"validation","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/9f775e8a12daef8255556097396f9b2739078892/kernel/model/cloud_service.go#L727-L763","documentation":"Conf.Language(294) is the localized message shown when an activation code is empty. UseActivationcode rejects the request before any network call because after stripping invalid characters and trimming whitespace the submitted code is the empty string.","triggerScenarios":"Calling model.UseActivationcode(code) (kernel/model/cloud_service.go:745) with an empty string, a string of only whitespace, or a string containing only characters removed by util.RemoveInvalid — e.g. the API consumer submitted the redemption form without filling in the code field.","commonSituations":"A frontend dialog submits an empty activation-code input; a script automating subscription redemption passes an unset/blank variable; a copied 'code' contained only formatting characters that RemoveInvalid strips.","solutions":["Provide a non-empty activation code in the request body and retry","Check the UI input for whitespace-only values and show a validation message before calling the kernel API","Re-copy the activation code from the purchase email/marketplace, ensuring no placeholder text or only invisible characters were selected"],"exampleFix":"// before\nawait fetchPost(\"/api/attr/useActivationcode\", {code: codeInput.value});\n// after\nif (!codeInput.value.trim()) { showMessage(window.siyuan.languages[\"_kernel\"][\"294\"]); return; }\nawait fetchPost(\"/api/attr/useActivationcode\", {code: codeInput.value.trim()});","handlingStrategy":"validation","validationCode":"const code = (codeInput?.value ?? \"\").trim();\nif (!code) { showMessage(window.siyuan.languages[\"_kernel\"][\"294\"]); return; }","typeGuard":"const hasCode = (v) => typeof v === \"string\" && v.trim().length > 0;","tryCatchPattern":"try {\n  const res = await fetchSyncPost(\"/api/attr/useActivationcode\", {code});\n  if (res.code !== 0) showMessage(res.msg);\n} catch (e) { showMessage(e.message); }","preventionTips":["Validate non-empty input in the form before submitting to the kernel API","Trim whitespace and strip invisible characters from pasted codes","Disable the submit button while the code field is empty"],"tags":["validation","empty-input","activation-code","i18n"],"backgroundTag":"empty-required-field","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"}