{"record":{"id":"acb70484cbac5702","repo":"siyuan-note/siyuan","slug":"failed-to-connect-cloud-server","errorCode":null,"errorMessage":"failed to connect cloud server","messagePattern":"failed to connect cloud server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/cloud_service.go","lineNumber":40,"sourceCode":"\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/88250/gulu\"\n\t\"github.com/88250/lute/parse\"\n\t\"github.com/siyuan-note/httpclient\"\n\t\"github.com/siyuan-note/logging\"\n\t\"github.com/siyuan-note/siyuan/kernel/conf\"\n\t\"github.com/siyuan-note/siyuan/kernel/task\"\n\t\"github.com/siyuan-note/siyuan/kernel/util\"\n)\n\nvar ErrFailedToConnectCloudServer = errors.New(\"failed to connect cloud server\")\n\nfunc CloudChatGPT(msg string, contextMsgs []string) (ret string, stop bool, err error) {\n\tuser := Conf.GetUser()\n\tif nil == user {\n\t\treturn\n\t}\n\tinvalidUser := cloudAccountAuthFailureHandler(user.UserToken)\n\n\tpayload := map[string]any{}\n\tvar messages []map[string]any\n\tfor _, contextMsg := range contextMsgs {\n\t\tmessages = append(messages, map[string]any{\n\t\t\t\"role\":    \"user\",\n\t\t\t\"content\": contextMsg,\n\t\t})\n\t}\n\tmessages = append(messages, map[string]any{\n\t\t\"role\":    \"user\",","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/cloud_service.go#L22-L58","documentation":"ErrFailedToConnectCloudServer (kernel/model/cloud_service.go:40) is the sentinel returned whenever a request to SiYuan's cloud (bazaar ratings, asset upload, AI chat, free trial, account operations, block reminders) fails at the transport level or comes back with an unexpected non-200 status. Callers log the underlying request error and substitute this sentinel, so the original network cause is only in the log, not in the returned error.","triggerScenarios":"Any cloud-bound HTTP call where reqErr != nil (DNS failure, timeout, TLS error, no network) — e.g. assets.go:1487 upload path, bazaar_rating.go:373 rating fetch — or an HTTP status that is neither 200 nor explicitly handled (401 is mapped to the localized not-logged-in error instead).","commonSituations":"Working offline or behind a corporate proxy/firewall; siyuan cloud maintenance/outage; stale DNS or blocked liuyun.io/bazaar endpoints in some regions; system clock breaks making TLS fail; using SiYuan without a network while features like AI chat or asset upload still trigger cloud calls.","solutions":["Check network connectivity and any proxy settings (system proxy or SiYuan's own proxy config) and retry the operation","Read the kernel log for the preceding 'upload assets failed' / 'request bazaar package rating failed' line to see the true underlying cause","Verify the cloud service is reachable (siyuan cloud status page) and wait out an outage; confirm no firewall blocks *.liuyun.io / ld246.com endpoints","Check for an updated SiYuan version if the cloud API endpoints changed; handle ErrFailedToConnectCloudServer with errors.Is and offer a retry with backoff in calling code"],"exampleFix":"// before\ncount, err := model.UploadAssets(...) // offline; err is opaque sentinel\n\n// after\nif errors.Is(err, model.ErrFailedToConnectCloudServer) {\n    ui.showMessage(\"Network unavailable - check your connection or proxy, then retry\")\n    // schedule retry with backoff\n}","handlingStrategy":"retry","validationCode":"// Go: check connectivity before cloud calls\nif err := quickCloudPing(); err != nil { return err } // fail fast offline","typeGuard":null,"tryCatchPattern":"if errors.Is(err, model.ErrFailedToConnectCloudServer) {\n    // check kernel log for root cause; retry with exponential backoff\n    scheduleRetry(op, backoff)\n}","preventionTips":["Check network/proxy availability before triggering cloud features","Read the kernel log line above the sentinel for the true cause","Implement retry with backoff for transient transport failures","Subscribe to cloud status to distinguish outages from local misconfig"],"tags":["network","cloud","http"],"backgroundTag":"http-request-failed","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"}