siyuan-note/siyuan · error

result["msg"] (cloud server message)

Error message

result["msg"] (cloud server message)

What it means

When the cloud server responds 200 but the JSON envelope's code field is non-zero, the request reached the server but the business operation failed. The server's msg field is logged and returned verbatim as the error (result["msg"].(string)). This error text is produced by the remote siyuan cloud API, not by local validation.

Solutions

  1. Read the returned msg (it is also in the kernel log as 'remove cloud shorthands failed: ...') to identify the server-side cause
  2. Refresh the shorthand list (GetCloudShorthands) and retry only with currently existing IDs
  3. Retry after a delay if msg indicates throttling or a transient server condition
  4. If the msg is persistent for valid IDs, check cloud service status / report the server error

Example fix

// before
ids := allCachedIds
err := model.RemoveCloudShorthands(ids) // server may reject unknown ids
// after
shorthands, err := model.GetCloudShorthands(0) // refresh first
// build ids from shorthands["data"].(map[string]any)["shorthands"] then retry
Defensive patterns

Strategy: try-catch

Validate before calling

// verify ids exist before removing
list, _ := model.GetCloudShorthands(0)
existing := shorthandIdSet(list)
for _, id := range ids { if !existing[id] { return fmt.Errorf("unknown shorthand %s", id) } }

Try / catch

if err := model.RemoveCloudShorthands(ids); err != nil {
    logging.LogWarnf("server rejected removal: %v", err)
    return err
}

Prevention

When it happens

Trigger: POST /apis/siyuan/inbox/removeCloudShorthands returns {code: !=0, msg: ...} — e.g. shorthand IDs that do not exist or belong to another account, rate limiting, or server-side restrictions on the operation.

Common situations: Passing stale shorthand IDs collected before the item was already deleted (or on the server) elsewhere; calling with IDs from a different account; cloud service maintenance or throttling producing server-defined error messages.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/65dcdc9f661c72d4. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/cloud_service.go:576

		logging.LogErrorf("remove cloud shorthands failed: %s", err)
		err = ErrFailedToConnectCloudServer
		return
	}

	if http.StatusUnauthorized == resp.StatusCode {
		invalidUser()
		err = errors.New(Conf.Language(31))
		return
	}
	if http.StatusOK != resp.StatusCode {
		err = ErrFailedToConnectCloudServer
		return
	}

	code := result["code"].(float64)
	if 0 != code {
		logging.LogErrorf("remove cloud shorthands failed: %s", result["msg"])
		err = errors.New(result["msg"].(string))
		return
	}
	return
}

func GetCloudShorthand(id string) (ret map[string]any, err error) {
	user := Conf.GetUser()
	if user == nil {
		return nil, errors.New(Conf.Language(31))
	}
	invalidUser := cloudAccountAuthFailureHandler(user.UserToken)
	result := map[string]any{}
	request := httpclient.NewCloudRequest30s()
	resp, err := request.
		SetSuccessResult(&result).
		SetCookies(&http.Cookie{Name: "symphony", Value: user.UserToken}).
		Post(util.GetCloudServer() + "/apis/siyuan/inbox/getCloudShorthand?id=" + id)
	if err != nil {

View on GitHub (pinned to 9f775e8a12)