{"record":{"id":"b5540280e93c99b9","repo":"siyuan-note/siyuan","slug":"result-msg-string","errorCode":null,"errorMessage":"result[\"msg\"].(string)","messagePattern":"result\\[\"msg\"\\]\\.\\(string\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/cloud_service.go","lineNumber":613,"sourceCode":"\t\tlogging.LogErrorf(\"get cloud shorthand failed: %s\", err)\n\t\terr = ErrFailedToConnectCloudServer\n\t\treturn\n\t}\n\n\tif http.StatusUnauthorized == resp.StatusCode {\n\t\tinvalidUser()\n\t\terr = errors.New(Conf.Language(31))\n\t\treturn\n\t}\n\tif http.StatusOK != resp.StatusCode {\n\t\terr = ErrFailedToConnectCloudServer\n\t\treturn\n\t}\n\n\tcode := result[\"code\"].(float64)\n\tif 0 != code {\n\t\tlogging.LogErrorf(\"get cloud shorthand failed: %s\", result[\"msg\"])\n\t\terr = errors.New(result[\"msg\"].(string))\n\t\treturn\n\t}\n\tret = result[\"data\"].(map[string]any)\n\tt, _ := strconv.ParseInt(id, 10, 64)\n\thCreated := util.Millisecond2Time(t)\n\tret[\"hCreated\"] = hCreated.Format(\"2006-01-02 15:04\")\n\n\tmd := ret[\"shorthandContent\"].(string)\n\tret[\"shorthandMd\"] = md\n\n\tluteEngine := NewLute()\n\tluteEngine.SetFootnotes(true)\n\ttree := parse.Parse(\"\", []byte(md), luteEngine.ParseOptions)\n\tluteEngine.RenderOptions.ProtyleMarkNetImg = false\n\tcontent := luteEngine.ProtylePreview(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)\n\tret[\"shorthandContent\"] = content\n\treturn\n}","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/cloud_service.go#L595-L631","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the returned msg / kernel log to identify the server-side reason","Verify the shorthand ID exists and belongs to the logged-in account (list via GetCloudShorthands)","If the item was deleted, treat it as gone rather than retrying","Retry with backoff only if msg suggests a transient server condition"],"exampleFix":"// before\nret, err := model.GetCloudShorthand(\"123456\") // may not exist\n// after\nlist, _ := model.GetCloudShorthands(0)\nif !shorthandExists(list, \"123456\") { return fmt.Errorf(\"shorthand %s not found\", \"123456\") }\nret, err = model.GetCloudShorthand(\"123456\")","handlingStrategy":"validation","validationCode":"// check the id is numeric and plausibly valid before the call\nif _, err := strconv.ParseInt(id, 10, 64); err != nil { return fmt.Errorf(\"bad shorthand id %q\", id) }","typeGuard":null,"tryCatchPattern":"ret, err := model.GetCloudShorthand(id)\nif err != nil {\n    if strings.Contains(err.Error(), \"not found\") { markItemGone(id); return nil }\n    return err\n}","preventionTips":["Only use IDs obtained from a fresh GetCloudShorthands listing","Do not reuse IDs across accounts or servers","Log the server msg before deciding to retry"],"tags":["cloud","api","remote-error"],"backgroundTag":"api-error-response","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}