{"record":{"id":"741864c20944f3af","repo":"AlistGo/alist","slug":"wukong-upload-to-tos-failed-code-d-message-s","errorCode":null,"errorMessage":"wukong upload to tos failed: code=%d message=%s","messagePattern":"wukong upload to tos failed: code=(.+?) message=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/wukong/driver.go","lineNumber":589,"sourceCode":"\t\tSetHeader(\"Host\", host).\n\t\tSetHeader(\"Referer\", webReferer).\n\t\tSetHeader(\"Origin\", \"https://pan.wkbrowser.com\").\n\t\tSetHeader(\"Authorization\", auth).\n\t\tSetHeader(\"Content-Type\", \"application/octet-stream\").\n\t\tSetHeader(\"Content-Crc32\", crc32Hex).\n\t\tSetHeader(\"Content-Disposition\", fmt.Sprintf(`attachment; filename=\"%s\"`, url.QueryEscape(fileName))).\n\t\tSetHeader(\"Content-Length\", strconv.FormatInt(size, 10)).\n\t\tSetBody(body).\n\t\tSetResult(&resp)\n\tif storageUser != \"\" {\n\t\treq.SetHeader(\"X-Storage-U\", storageUser)\n\t}\n\t_, err := req.Post(uploadURL)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.Code != minUploadSubmitSuccess {\n\t\treturn fmt.Errorf(\"wukong upload to tos failed: code=%d message=%s\", resp.Code, resp.Message)\n\t}\n\tif resp.Data.Crc32 != \"\" && !strings.EqualFold(resp.Data.Crc32, crc32Hex) {\n\t\treturn fmt.Errorf(\"wukong upload to tos crc32 mismatch: local=%s remote=%s\", crc32Hex, resp.Data.Crc32)\n\t}\n\treturn nil\n}\n\nfunc (d *Wukong) uploadToTOSMultipart(ctx context.Context, host, storeURI, auth, storageUser string, tempFile model.File, size int64, up driver.UpdateProgress) error {\n\tuploadID, err := d.initMultipartUpload(ctx, host, storeURI, auth, storageUser)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttotalParts := int((size + multipartChunkSize - 1) / multipartChunkSize)\n\tif totalParts <= 0 {\n\t\treturn errors.New(\"invalid multipart parts\")\n\t}\n\tparts := make([]string, 0, totalParts)","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/wukong/driver.go#L571-L607","documentation":"Thrown by uploadToTOS after POSTing the file body directly to https://<host>/upload/v1/<storeURI>. The TOS upload endpoint responded with a code other than 2000 (minUploadSubmitSuccess). The storage layer (Volcengine TOS fronted by Wukong) rejected the transfer — commonly auth, expiry, or host issues.","triggerScenarios":"Authorization header (from ApplyUploadInner) expired during a slow upload; X-Storage-U missing when storageUser required; upload host from candidates unreachable/decommissioned; Content-Length/Content-Disposition malformed; body truncated.","commonSituations":"Large single-request uploads exceeding token validity; best-host selection picking a dead node (ClientBestHosts fallback not exercised); proxy or CDN in front mangling headers.","solutions":["Retry via the multipart path (uploadToTOSMultipart) or re-run applyUploadInner to get fresh auth and hosts","Ensure storageUser is set on the request when provided by ApplyUploadInner","Confirm Content-Length matches the exact byte count being sent","If resp.Message shows auth/expiry, mint a new auth token and restart the TOS transfer"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := d.uploadToTOS(ctx, host, storeURI, auth, storageUser, tempFile, size); err != nil {\n    if strings.Contains(err.Error(), \"auth\") || strings.Contains(err.Error(), \"expire\") {\n        // re-apply for fresh auth, then retry once\n        return d.restartAndUpload(ctx)\n    }\n    return err\n}","preventionTips":["Prefer multipart for large files so slow transfers can outlive token issues part-by-part","Always forward X-Storage-U when the apply step provides it","Set Content-Length exactly; mismatched lengths are rejected by the TOS front door"],"tags":["wukong","upload","tos","storage","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}