{"record":{"id":"38d0103849bd130c","repo":"siyuan-note/siyuan","slug":"backup-failed-s","errorCode":null,"errorMessage":"Backup failed: %s","messagePattern":"Backup failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/repository.go","lineNumber":1549,"sourceCode":"\t\t\treturn\n\t\t}\n\tcase conf.ProviderWebDAV, conf.ProviderS3, conf.ProviderLocal:\n\t\tif !IsPaidUser() {\n\t\t\tutil.PushErrMsg(Conf.Language(214), 5000)\n\t\t\treturn\n\t\t}\n\t}\n\n\tutil.PushEndlessProgress(Conf.Language(116))\n\tdefer util.PushClearProgress()\n\tuploadFileCount, uploadChunkCount, uploadBytes, err := repo.UploadTagIndex(tag, id, map[string]any{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})\n\tif err != nil {\n\t\tif errors.Is(err, dejavu.ErrCloudBackupCountExceeded) {\n\t\t\terr = fmt.Errorf(Conf.Language(84), Conf.Language(154))\n\t\t\treturn\n\t\t}\n\t\thandleCloudError(err)\n\t\terr = fmt.Errorf(Conf.Language(84), formatRepoErrorMsg(err))\n\t\treturn\n\t}\n\tmsg := fmt.Sprintf(Conf.Language(152), uploadFileCount, uploadChunkCount, humanize.BytesCustomCeil(uint64(uploadBytes), 2))\n\tutil.PushMsg(msg, 5000)\n\tutil.PushStatusBar(msg)\n\treturn\n}\n\nfunc RemoveCloudRepoTag(tag string) (err error) {\n\tassetDownloadSourceMu.RLock()\n\tdefer assetDownloadSourceMu.RUnlock()\n\tif 1 > len(Conf.Repo.Key) {\n\t\terr = errors.New(Conf.Language(26))\n\t\treturn\n\t}\n\n\thandleCloudError := cloudRepoErrorHandler()\n\tdefer func() { handleCloudError(err) }()","sourceCodeStart":1531,"sourceCodeEnd":1567,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/repository.go#L1531-L1567","documentation":"This is the generic failure branch of UploadCloudSnapshot: after UploadTagIndex fails with any error that is not ErrCloudBackupCountExceeded, the kernel calls handleCloudError (which may surface account/network diagnostics), then wraps the cause with formatRepoErrorMsg into the localized 'Backup failed: %s' template (Language 84). The %s payload is a humanized repo error, so this message is an envelope whose real cause is embedded in the suffix.","triggerScenarios":"UploadTagIndex inside UploadCloudSnapshot fails for reasons other than the 12-snapshot quota: network failure mid-upload, cloud authentication failure (invalid/changed token), corrupted local index, or cloud-side 5xx responses.","commonSituations":"Uploading a large snapshot over an unstable connection; SiYuan Cloud session token expired after password change; cloud service maintenance returning HTTP errors; local repo key mismatch after restoring config from another machine.","solutions":["Read the %s suffix in the error to identify the underlying repo error and fix that cause first","Verify the cloud account is logged in (Settings - Account) and the subscription is active; re-login to refresh the token","Check network connectivity/proxy settings and retry, since uploads resume incrementally","Inspect kernel logs for the handleCloudError diagnostics (e.g. 401/403/5xx details) for the precise failure","If the error persists for one snapshot, create a fresh snapshot tag and upload that instead"],"exampleFix":"// before\nif err != nil {\n    return fmt.Errorf(\"backup failed\")\n}\n// after\nif err != nil {\n    if errors.Is(err, dejavu.ErrCloudBackupCountExceeded) {\n        return fmt.Errorf(Conf.Language(84), Conf.Language(154))\n    }\n    handleCloudError(err)\n    return fmt.Errorf(Conf.Language(84), formatRepoErrorMsg(err))\n}","handlingStrategy":"retry","validationCode":"// pre-check reachability and login before a long upload\nconst me = await fetchPost('/api/account/info', {});\nif (!me.data || me.code !== 0) throw new Error('Not logged in to SiYuan Cloud');","typeGuard":null,"tryCatchPattern":"try {\n    await fetchPost('/api/repo/uploadCloudSnapshot', {tag, id});\n} catch (e) {\n    // parse the '%s' suffix of 'Backup failed: %s' for the repo error cause\n    console.error('cloud backup cause:', e.msg);\n    if (isTransient(e)) await sleep(retryBackoff); // retry network failures only\n}","preventionTips":["Ensure a stable connection and valid cloud session before large uploads","Re-login after password changes so the cloud token stays fresh","Monitor kernel logs for handleCloudError diagnostics (HTTP status codes)","Create a fresh snapshot tag and retry when one snapshot's index is corrupt"],"tags":["cloud","backup","network","sync","api-error"],"backgroundTag":"http-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"}