siyuan-note/siyuan · error
result["msg"].(string)
Error message
result["msg"].(string)
What it means
In RemoveCloudShorthands, returned when the cloud server responds with HTTP 200 but result['code'] (float64) is non-zero. The server's result['msg'] is extracted via a type assertion to string and wrapped in errors.New. This is a pass-through of a server-side business error from the inbox removal endpoint.
Source
Thrown at kernel/model/cloud_service.go:450
SetSuccessResult(&result).
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.GetUser().UserToken}).
SetBody(body).
Post(util.GetCloudServer() + "/apis/siyuan/inbox/removeCloudShorthands")
if err != nil {
logging.LogErrorf("remove cloud shorthands failed: %s", err)
err = ErrFailedToConnectCloudServer
return
}
if 401 == resp.StatusCode {
err = errors.New(Conf.Language(31))
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) {
result := map[string]any{}
request := httpclient.NewCloudRequest30s()
resp, err := request.
SetSuccessResult(&result).
SetCookies(&http.Cookie{Name: "symphony", Value: Conf.GetUser().UserToken}).
Post(util.GetCloudServer() + "/apis/siyuan/inbox/getCloudShorthand?id=" + id)
if err != nil {
logging.LogErrorf("get cloud shorthand failed: %s", err)
err = ErrFailedToConnectCloudServer
return
}
View on GitHub (pinned to 251596fc0d)
Solutions
- Show result['msg'] to the user as the specific reason.
- Refresh the cloud shorthand list and retry only existing, owned shorthands.
- Defensively, the kernel should guard the result['msg'].(string) assertion to avoid a panic when msg is missing or non-string.
Example fix
// before (kernel-side risk): direct assertion can panic
err = errors.New(result["msg"].(string))
// after (kernel-side safe)
msg, _ := result["msg"].(string)
if msg == "" { msg = "remove cloud shorthands failed" }
err = errors.New(msg) Defensive patterns
Strategy: try-catch
Validate before calling
// Refresh the shorthand list and only delete ids that still exist and are owned ids := filterOwnedShorthands(cachedIds)
Type guard
func isServerBusinessError(err error) bool {
return err != nil && !errors.Is(err, model.ErrFailedToConnectCloudServer) && !isAuthError(err)
} Try / catch
if err := model.RemoveCloudShorthands(ids); err != nil {
if errors.Is(err, model.ErrFailedToConnectCloudServer) { retry() }
else if isAuthError(err) { reloginAndRetry() }
else { showUser(err.Error()) /* result[msg] */ }
} Prevention
- Refresh the shorthand list before deleting to drop stale ids.
- Kernel-side: guard the result["msg"].(string) assertion with a comma-ok form to avoid panics.
- Show the server message verbatim for actionable detail.
When it happens
Trigger: POST /apis/siyuan/inbox/removeCloudShorthands succeeds at the HTTP level but the JSON envelope code != 0, e.g. one of the shorthand ids does not belong to the user, does not exist, or the inbox service rejected the batch. Note: this code path performs a .(string) type assertion on result['msg'] which will panic if msg is not a string.
Common situations: A shorthand id in the batch was already deleted; ids belong to another account; server-side inbox inconsistency; concurrent deletion from another device.
Related errors
- requestResult.Msg
- --id is required
- failed to connect cloud server
- Account authentication failed, please login again
- You have already used a free trial subscription. Duplicate t
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/b5540280e93c99b9.
Report an issue: GitHub.