AlistGo/alist · error

failed to initialize multipart upload: %w

Error message

failed to initialize multipart upload: %w

What it means

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.

Source

Thrown at drivers/doubao/util.go:511

		IsFolder: false,
	}, nil
}

// UploadByMultipart 分片上传
func (d *Doubao) UploadByMultipart(ctx context.Context, config *UploadConfig, fileSize int64, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress, dataType string) (model.Obj, error) {
	// 构建请求路径
	uploadNode := config.InnerUploadAddress.UploadNodes[0]
	storeInfo := uploadNode.StoreInfos[0]
	uploadUrl := fmt.Sprintf("https://%s/upload/v1/%s", uploadNode.UploadHost, storeInfo.StoreURI)
	// 初始化分片上传
	var uploadID string
	err := d._retryOperation("Initialize multipart upload", func() error {
		var err error
		uploadID, err = d.initMultipartUpload(config, uploadUrl, storeInfo)
		return err
	})
	if err != nil {
		return nil, fmt.Errorf("failed to initialize multipart upload: %w", err)
	}
	// 准备分片参数
	chunkSize := DefaultChunkSize
	if config.InnerUploadAddress.AdvanceOption.SliceSize > 0 {
		chunkSize = int64(config.InnerUploadAddress.AdvanceOption.SliceSize)
	}
	totalParts := (fileSize + chunkSize - 1) / chunkSize
	// 创建分片信息组
	parts := make([]UploadPart, totalParts)
	// 缓存文件
	tempFile, err := file.CacheFullInTempFile()
	if err != nil {
		return nil, fmt.Errorf("failed to cache file: %w", err)
	}
	defer tempFile.Close()
	up(10.0) // 更新进度
	// 设置并行上传
	threadG, uploadCtx := errgroup.NewGroupWithContext(ctx, d.uploadThread,

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Refresh credentials (re-login) and retry — stale STS credentials are the leading cause of signature-rejected initialization
  2. Check server clock sync (V4 signatures include timestamps; skew breaks them)
  3. Retry the whole upload to get a fresh upload-config and StoreURI
  4. Look at the wrapped error: 403 → signing/token; timeout → network to upload host

Example fix

// before
if err != nil {
	return nil, fmt.Errorf("failed to initialize multipart upload: %w", err)
}
// after — include uploadUrl host for correlation
if err != nil {
	return nil, fmt.Errorf("failed to initialize multipart upload at %s: %w", uploadUrl, err)
}
Defensive patterns

Strategy: retry

Validate before calling

if _, err := d.GetUserInfo(ctx); err != nil {
	return fmt.Errorf("refresh credentials before multipart init: %w", err)
}

Try / catch

if strings.Contains(err.Error(), "failed to initialize multipart upload") {
	if isSignatureError(err) { return reloginThenRetry() } // stale STS
	return backoffRetry(3)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/32529c4af764dd67. Report an issue: GitHub.