AlistGo/alist · error
[doubao_new] merge blocks invalid block origin size
Error message
[doubao_new] merge blocks invalid block origin size
What it means
mergeUploadBlocks validates its arguments before POSTing the merge_block request to internal-api-drive-stream.feishu.cn. blockOriginSize is the fixed block size the server told the client to use (sent as the x-block-origin-size header, util.go:730) and the caller passes the blockSize obtained from the upload-prepare response (driver.go:311). A value <= 0 means the prepare step returned no usable block size, so the merge request could not be built.
Source
Thrown at drivers/doubao_new/util.go:709
}
return resp.Data, nil
}
func (d *DoubaoNew) mergeUploadBlocks(ctx context.Context, uploadID string, seqList []int, checksumList []string, sizeList []int64, blockOriginSize int64, data []byte) (UploadMergeData, error) {
if uploadID == "" {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks missing upload_id")
}
if len(seqList) == 0 {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks empty seq list")
}
if len(checksumList) == 0 {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks empty checksum list")
}
if len(sizeList) != len(seqList) {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks size list mismatch")
}
if blockOriginSize <= 0 {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks invalid block origin size")
}
if len(data) == 0 {
return UploadMergeData{}, fmt.Errorf("[doubao_new] merge blocks empty data")
}
seqHeader := joinIntComma(seqList)
checksumHeader := buildCommaHeader(checksumList)
client := base.NewRestyClient()
client.SetCookieJar(nil)
req := client.R()
req.SetContext(ctx)
req.SetHeader("accept", "application/json, text/plain, */*")
req.SetHeader("origin", "https://www.doubao.com")
req.SetHeader("referer", "https://www.doubao.com/")
req.SetHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36")
req.SetHeader("rpc-persist-doubao-pan", "true")
req.SetHeader("content-type", "application/octet-stream")View on GitHub (pinned to 843d9dc814)
Solutions
- Inspect the upload-prepare response (decode and log it) and confirm which JSON field carries the block size; fix the struct tag in types.go if the field name changed.
- Guard the prepare result before uploading: fail fast with a clear error if UploadPrep.BlockSize <= 0 instead of propagating it into mergeUploadBlocks.
- If the file is empty (size 0), skip the block-upload/merge path entirely and use the direct/finish upload path.
- Retry with a fresh login/token: an expired or downgraded session can make prepare return a partial payload with code 0 but no data.
Example fix
// before
mergeResp, err := d.mergeUploadBlocks(ctx, uploadPrep.UploadID, groupSeqs, groupChecksums, groupSizes, blockSize, data)
// after
if blockSize <= 0 {
return nil, fmt.Errorf("[doubao_new] upload prepare returned invalid block size: %d", blockSize)
}
mergeResp, err := d.mergeUploadBlocks(ctx, uploadPrep.UploadID, groupSeqs, groupChecksums, groupSizes, blockSize, data) Defensive patterns
Strategy: validation
Validate before calling
// before uploading, verify the prepare result is usable
if uploadPrep.UploadID == "" || uploadPrep.BlockSize <= 0 {
return fmt.Errorf("[doubao_new] upload prepare unusable: upload_id=%q block_size=%d", uploadPrep.UploadID, uploadPrep.BlockSize)
} Prevention
- Validate prepare responses (upload_id present, block size > 0) immediately, before any block work.
- Route zero-byte files around the chunked path.
- Log the raw prepare response once when schema changes are suspected.
When it happens
Trigger: Calling mergeUploadBlocks when the upload-prepare API returned BlockSize/BlockOriginSize of 0 or a negative value (empty field, changed response schema, or API change), or a custom caller passing a hardcoded 0. Triggered on any Put of a file large enough to need >= 1 block upload.
Common situations: Doubao/Feishu internal API changed its prepare response shape so the block-size field no longer unmarshals; uploading an empty or very small file whose prepare returns no block size; a driver update that renames the JSON field and silently leaves blockSize zero.
Related errors
- init upload failed: %s
- upload part failed: %s
- finish upload failed: %s
- [doubao_new] merge blocks empty data
- [doubao_new] v3 fallback invalid size: seq=%d size=%d
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/b9c9d7474262ea31.
Report an issue: GitHub.