siyuan-note/siyuan · warning

Conf.Language(294)

Error message

Conf.Language(294)

What it means

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.

Source

Thrown at kernel/model/cloud_service.go:745

		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))
	}
	user := Conf.GetUser()
	if user == nil {
		return errors.New(Conf.Language(31))
	}
	invalidUser := cloudAccountAuthFailureHandler(user.UserToken)
	requestResult := gulu.Ret.NewResult()
	request := httpclient.NewCloudRequest30s()
	resp, err := request.
		SetSuccessResult(requestResult).
		SetBody(map[string]string{"data": code}).
		SetCookies(&http.Cookie{Name: "symphony", Value: user.UserToken}).
		Post(util.GetCloudServer() + "/apis/siyuan/useActivationcode")
	if err != nil {
		logging.LogErrorf("check activation code failed: %s", err)
		return ErrFailedToConnectCloudServer
	}
	if http.StatusUnauthorized == resp.StatusCode {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Enter a valid activation code in Settings - Account before submitting
  2. Trim and validate the code client-side before calling the endpoint
  3. If the clipboard paste appears non-empty but fails, check for whitespace-only or unsupported characters

Example fix

// before
fetchPost('/api/account/useActivationcode', {code: ''})
// after
const code = inputEl.value.trim();
if (!code) { showMessage(window.siyuan.languages[294]); return; }
fetchPost('/api/account/useActivationcode', {code})
Defensive patterns

Strategy: validation

Validate before calling

const code = (input.value || '').trim();
if (!code) { showMessage(window.siyuan.languages[294]); return; }

Type guard

function hasActivationCode(v: unknown): v is string {
  return typeof v === "string" && v.trim().length > 0;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/79b866910c7edd96. Report an issue: GitHub.