siyuan-note/siyuan · warning
Activation code cannot be empty
Error message
Activation code cannot be empty
What it means
UseActivationcode rejects an empty activation code. The input is first passed through util.RemoveInvalid and strings.TrimSpace; if nothing remains, the function returns Conf.Language(294) (the localized 'activation code cannot be empty' message). This is intentional input validation before any network call is made.
Source
Thrown at kernel/model/cloud_service.go:596
logging.LogErrorf("get community user failed: %s", result["msg"])
return nil, errRequestUserFailed
}
dataStr := result["data"].(string)
data := util.AESDecrypt(dataStr)
user := &conf.User{}
if err = gulu.JSON.UnmarshalJSON(data, &user); err != nil {
logging.LogErrorf("get community user failed: %s", err)
return nil, errRequestUserFailed
}
return user, nil
}
func UseActivationcode(code string) (err error) {
code = util.RemoveInvalid(code)
code = strings.TrimSpace(code)
if "" == code {
return errors.New(Conf.Language(294))
}
requestResult := gulu.Ret.NewResult()
request := httpclient.NewCloudRequest30s()
resp, err := request.
SetSuccessResult(requestResult).
SetBody(map[string]string{"data": code}).
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.GetUser().UserToken}).
Post(util.GetCloudServer() + "/apis/siyuan/useActivationcode")
if err != nil {
logging.LogErrorf("check activation code failed: %s", err)
return ErrFailedToConnectCloudServer
}
if http.StatusOK != resp.StatusCode {
logging.LogErrorf("check activation code failed: %d", resp.StatusCode)
return ErrFailedToConnectCloudServer
}
if 0 != requestResult.Code {
return errors.New(requestResult.Msg)View on GitHub (pinned to 251596fc0d)
Solutions
- Validate the code is non-empty on the caller side before invoking UseActivationcode.
- Trim and check the input in the UI layer and disable the submit action until a non-empty value is present.
- If calling programmatically, guard with `if strings.TrimSpace(code) == "" { return }` before the call.
Example fix
// before
err := model.UseActivationcode("")
// after
code = strings.TrimSpace(code)
if code == "" {
return errors.New("activation code required")
}
err := model.UseActivationcode(code) Defensive patterns
Strategy: validation
Validate before calling
// Validate activation code before calling UseActivationcode.
func validateActivationCode(code string) error {
code = strings.TrimSpace(code)
if code == "" {
return errors.New("activation code is required")
}
return nil
} Prevention
- Trim and check the activation code in the UI layer; disable submit until non-empty.
- Treat empty-string returns from the model layer as a user-input signal, not a system fault.
- When calling programmatically, assert `strings.TrimSpace(code) != ""` before the call.
When it happens
Trigger: Call to UseActivationcode with an empty string, a whitespace-only string, or a string composed entirely of characters stripped by util.RemoveInvalid. Triggered from the activation-code UI when the user submits without typing, or programmatically with a blank value.
Common situations: User clicks the activate button without entering a code; clipboard paste of whitespace; automation/CLI passing an unset variable; frontend validation bypassed.
Related errors
- --id is required
- invalid notebook ID
- OIDC claim rule values cannot be empty
- Conf.Language(142)
- Conf.Language(151)
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/7ffd9725e97fbec1.
Report an issue: GitHub.