{"record":{"id":"30d37f8e2ff70e8a","repo":"siyuan-note/siyuan","slug":"upload-failed-s","errorCode":null,"errorMessage":"Upload failed: %s","messagePattern":"Upload failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/assets.go","lineNumber":1348,"sourceCode":"\t\t\tSetSuccessResult(requestResult).\n\t\t\tSetFile(\"file[]\", absAsset).\n\t\t\tSetCookies(&http.Cookie{Name: \"symphony\", Value: uploadToken}).\n\t\t\tSetHeader(\"meta-type\", metaType).\n\t\t\tSetHeader(\"biz-type\", bizType).\n\t\t\tPost(util.GetCloudServer() + \"/apis/siyuan/upload?ver=\" + util.Ver)\n\t\tif nil != reqErr {\n\t\t\tlogging.LogErrorf(\"upload assets failed: %s\", reqErr)\n\t\t\treturn count, ErrFailedToConnectCloudServer\n\t\t}\n\n\t\tif 401 == resp.StatusCode {\n\t\t\terr = errors.New(Conf.Language(31))\n\t\t\treturn\n\t\t}\n\n\t\tif 0 != requestResult.Code {\n\t\t\tlogging.LogErrorf(\"upload assets failed: %s\", requestResult.Msg)\n\t\t\terr = fmt.Errorf(Conf.Language(94), requestResult.Msg)\n\t\t\treturn\n\t\t}\n\n\t\tabsAsset = filepath.ToSlash(absAsset)\n\t\trelAsset := absAsset[strings.Index(absAsset, \"assets/\"):]\n\t\tcompletedUploadAssets = append(completedUploadAssets, relAsset)\n\t\tlogging.LogInfof(\"uploaded asset [%s]\", relAsset)\n\t\tcount++\n\t}\n\n\tif !ignorePushMsg {\n\t\tutil.PushClearMsg(msgId)\n\t}\n\n\tif 0 < len(completedUploadAssets) {\n\t\tlogging.LogInfof(\"uploaded [%d] assets\", len(completedUploadAssets))\n\t}\n\treturn","sourceCodeStart":1330,"sourceCodeEnd":1366,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/assets.go#L1330-L1366","documentation":"Returned by UploadAssets2Cloud (assets.go:1348) when the cloud upload endpoint returns a non-zero business code in requestResult.Code. The message is the kernel i18n key 94 (\"Upload failed: %s\") formatted with requestResult.Msg — the server-side reason string. The HTTP status is not 401 (that is error 420) and the request did not fail at the transport layer (that yields ErrFailedToConnectCloudServer).","triggerScenarios":"Posting a file to /apis/siyuan/upload whose size exceeds the server quota, whose MIME type is rejected, when the account is over its storage quota, when the cloud rejects the meta-type/biz-type combination, or when the server returns any application-level error code (requestResult.Code != 0) with a descriptive Msg.","commonSituations":"Non-subscriber uploading a file larger than 3 MB (limitSize guard is client-side at 3 MB / 10 MB, but the server re-validates); uploading to Liandi with an asset the server deems invalid; transient server-side maintenance returning an error code; subscription lapse shrinking the server-side quota.","solutions":["Read requestResult.Msg (surfaced in the formatted error) — it is the authoritative server reason; address that specific cause first (shrink the file, change type, free quota).","Confirm the file passes the client size gate (limitSize = 3 MB free / 10 MB subscriber) before relying on the cloud; the client gate only logs a warning and skips, so an oversized file can still reach the server via other code paths.","Re-authenticate (error 420) only if the message indicates auth; otherwise retry after resolving the server-reported cause."],"exampleFix":"// before: only the wrapped message reaches the caller\nerr = fmt.Errorf(Conf.Language(94), requestResult.Msg)\n\n// after: keep the server code for diagnosability\nerr = fmt.Errorf(\"%s (code %d)\", fmt.Sprintf(Conf.Language(94), requestResult.Msg), requestResult.Code)","handlingStrategy":"try-catch","validationCode":"// Pre-flight: enforce the client size gate the kernel uses (3 MB free / 10 MB subscriber).\nconst limit = window.siyuan.user?.siyuanSubscriptionStatus === 0 ? 10 : 3\nfor (const f of assets) {\n  if (f.size > limit * 1024 * 1024) { showMessage(`${f.name} exceeds ${limit} MB`); return }\n}","typeGuard":null,"tryCatchPattern":"// Surface the server's reason string and the code for diagnosability.\ntry {\n  await uploadAssets2Cloud(assets, 'upload-assets')\n} catch (e) {\n  // e.message is \"Upload failed: <server Msg>\"; show it verbatim, do not mask.\n  showMessage(e.message)\n}","preventionTips":["Honor the 3 MB / 10 MB size limit client-side before upload to avoid most server rejections.","Read requestResult.Msg from the error text — it is the authoritative server reason.","Validate file type against the cloud allowlist before sending."],"tags":["cloud","upload","assets","i18n","server-error"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}