{"record":{"id":"32529c4af764dd67","repo":"AlistGo/alist","slug":"failed-to-initialize-multipart-upload-w","errorCode":null,"errorMessage":"failed to initialize multipart upload: %w","messagePattern":"failed to initialize multipart upload: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/doubao/util.go","lineNumber":511,"sourceCode":"\t\tIsFolder: false,\n\t}, nil\n}\n\n// UploadByMultipart 分片上传\nfunc (d *Doubao) UploadByMultipart(ctx context.Context, config *UploadConfig, fileSize int64, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress, dataType string) (model.Obj, error) {\n\t// 构建请求路径\n\tuploadNode := config.InnerUploadAddress.UploadNodes[0]\n\tstoreInfo := uploadNode.StoreInfos[0]\n\tuploadUrl := fmt.Sprintf(\"https://%s/upload/v1/%s\", uploadNode.UploadHost, storeInfo.StoreURI)\n\t// 初始化分片上传\n\tvar uploadID string\n\terr := d._retryOperation(\"Initialize multipart upload\", func() error {\n\t\tvar err error\n\t\tuploadID, err = d.initMultipartUpload(config, uploadUrl, storeInfo)\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to initialize multipart upload: %w\", err)\n\t}\n\t// 准备分片参数\n\tchunkSize := DefaultChunkSize\n\tif config.InnerUploadAddress.AdvanceOption.SliceSize > 0 {\n\t\tchunkSize = int64(config.InnerUploadAddress.AdvanceOption.SliceSize)\n\t}\n\ttotalParts := (fileSize + chunkSize - 1) / chunkSize\n\t// 创建分片信息组\n\tparts := make([]UploadPart, totalParts)\n\t// 缓存文件\n\ttempFile, err := file.CacheFullInTempFile()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to cache file: %w\", err)\n\t}\n\tdefer tempFile.Close()\n\tup(10.0) // 更新进度\n\t// 设置并行上传\n\tthreadG, uploadCtx := errgroup.NewGroupWithContext(ctx, d.uploadThread,","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/doubao/util.go#L493-L529","documentation":"Before sending any part of a large file, the driver calls initMultipartUpload (wrapped in _retryOperation) to obtain an uploadID from the upload URL. This error means that initialization failed after the driver's internal retries — no parts were transmitted and the upload aborted.","triggerScenarios":"initMultipartUpload fails on: signed request rejected (403 signature mismatch due to stale STS token from Alice/Samantha), upload host unreachable, or the backend refusing the StoreURI (expired upload-config session). _retryOperation already retried, so this is a persistent failure.","commonSituations":"Upload-config fetched long before the actual upload begins (token expires in between); clock skew breaking the V4 signature; network issues with the specific upload host.","solutions":["Refresh credentials (re-login) and retry — stale STS credentials are the leading cause of signature-rejected initialization","Check server clock sync (V4 signatures include timestamps; skew breaks them)","Retry the whole upload to get a fresh upload-config and StoreURI","Look at the wrapped error: 403 → signing/token; timeout → network to upload host"],"exampleFix":"// before\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to initialize multipart upload: %w\", err)\n}\n// after — include uploadUrl host for correlation\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to initialize multipart upload at %s: %w\", uploadUrl, err)\n}","handlingStrategy":"retry","validationCode":"if _, err := d.GetUserInfo(ctx); err != nil {\n\treturn fmt.Errorf(\"refresh credentials before multipart init: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"failed to initialize multipart upload\") {\n\tif isSignatureError(err) { return reloginThenRetry() } // stale STS\n\treturn backoffRetry(3)\n}","preventionTips":["Fetch upload-config and start uploading promptly to keep STS fresh","Keep server clocks NTP-synced for V4 signatures","Re-login when 403s cluster around signature steps"],"tags":["doubao","multipart-upload","signing","upload"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}