siyuan-note/siyuan · error

result["msg"].(string)

Error message

result["msg"].(string)

What it means

When GetCloudShorthand receives HTTP 200 but the response envelope carries a non-zero code, the server rejected the business operation. The server-provided msg string is logged ('get cloud shorthand failed: ...') and returned as the error verbatim.

Solutions

  1. Check the returned msg / kernel log to identify the server-side reason
  2. Verify the shorthand ID exists and belongs to the logged-in account (list via GetCloudShorthands)
  3. If the item was deleted, treat it as gone rather than retrying
  4. Retry with backoff only if msg suggests a transient server condition

Example fix

// before
ret, err := model.GetCloudShorthand("123456") // may not exist
// after
list, _ := model.GetCloudShorthands(0)
if !shorthandExists(list, "123456") { return fmt.Errorf("shorthand %s not found", "123456") }
ret, err = model.GetCloudShorthand("123456")
Defensive patterns

Strategy: validation

Validate before calling

// check the id is numeric and plausibly valid before the call
if _, err := strconv.ParseInt(id, 10, 64); err != nil { return fmt.Errorf("bad shorthand id %q", id) }

Try / catch

ret, err := model.GetCloudShorthand(id)
if err != nil {
    if strings.Contains(err.Error(), "not found") { markItemGone(id); return nil }
    return err
}

Prevention

When it happens

Trigger: POST /apis/siyuan/inbox/getCloudShorthand?id=<id> returns {code: !=0, msg: ...} — e.g. the shorthand ID does not exist, belongs to another account, or the item was deleted server-side.

Common situations: Using an ID parsed from a stale collect URL after the item was removed; typos or truncated IDs in the query string; account switching so the ID belongs to a different user; server-side throttling.

Related errors


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

Appendix: source

Thrown at kernel/model/cloud_service.go:613

		logging.LogErrorf("get cloud shorthand 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("get cloud shorthand failed: %s", result["msg"])
		err = errors.New(result["msg"].(string))
		return
	}
	ret = result["data"].(map[string]any)
	t, _ := strconv.ParseInt(id, 10, 64)
	hCreated := util.Millisecond2Time(t)
	ret["hCreated"] = hCreated.Format("2006-01-02 15:04")

	md := ret["shorthandContent"].(string)
	ret["shorthandMd"] = md

	luteEngine := NewLute()
	luteEngine.SetFootnotes(true)
	tree := parse.Parse("", []byte(md), luteEngine.ParseOptions)
	luteEngine.RenderOptions.ProtyleMarkNetImg = false
	content := luteEngine.ProtylePreview(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)
	ret["shorthandContent"] = content
	return
}

View on GitHub (pinned to 9f775e8a12)