{"record":{"id":"b5c13e422eed9ca4","repo":"AlistGo/alist","slug":"doubao-new-merge-blocks-invalid-body-len-got-d","errorCode":null,"errorMessage":"[doubao_new] merge blocks invalid body len: got=%d expect=%d seqs=%v","messagePattern":"\\[doubao_new\\] merge blocks invalid body len: got=(.+?) expect=(.+?) seqs=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/doubao_new/driver.go","lineNumber":309,"sourceCode":"\n\t\tflushGroup := func() error {\n\t\t\tif len(groupSeqs) == 0 {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tdata := groupBuf.Bytes()\n\t\t\texpectLen := groupExpectSum\n\t\t\tif len(data) > 0 {\n\t\t\t\theadLen := 32\n\t\t\t\tif len(data) < headLen {\n\t\t\t\t\theadLen = len(data)\n\t\t\t\t}\n\t\t\t\ttailLen := 32\n\t\t\t\tif len(data) < tailLen {\n\t\t\t\t\ttailLen = len(data)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif int64(len(data)) != expectLen {\n\t\t\t\treturn fmt.Errorf(\"[doubao_new] merge blocks invalid body len: got=%d expect=%d seqs=%v\", len(data), expectLen, groupSeqs)\n\t\t\t}\n\t\t\tmergeResp, err := d.mergeUploadBlocks(ctx, uploadPrep.UploadID, groupSeqs, groupChecksums, groupSizes, blockSize, data)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif len(mergeResp.SuccessSeqList) != len(groupSeqs) {\n\t\t\t\treturn fmt.Errorf(\"[doubao_new] merge blocks incomplete: %v\", mergeResp.SuccessSeqList)\n\t\t\t}\n\t\t\tsuccess := make(map[int]bool, len(mergeResp.SuccessSeqList))\n\t\t\tfor _, seq := range mergeResp.SuccessSeqList {\n\t\t\t\tsuccess[seq] = true\n\t\t\t}\n\t\t\tfor _, seq := range groupSeqs {\n\t\t\t\tif !success[seq] {\n\t\t\t\t\treturn fmt.Errorf(\"[doubao_new] merge blocks missing seq %d\", seq)\n\t\t\t\t}\n\t\t\t}\n","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/doubao_new/driver.go#L291-L327","documentation":"Doubao_new driver (new web API) merge-group sanity check: the concatenated block buffer for a merge group does not have the byte length accumulated in groupExpectSum from the server-provided per-block sizes. The client refuses to send a merge request whose declared sizes wouldn't match its body.","triggerScenarios":"During incremental upload (dedup by block checksums), when the group of needed blocks read from the local temp file has total bytes != sum of item.Size values from the NeededUploadBlocks list — e.g. a short read silently accepted, block size list changed between queries, or blockMeta offsets inconsistent with blockSize.","commonSituations":"Temp file truncated (disk full while spooling), concurrent writers to the temp file, server returning updated block metadata after re-query, or a driver bug in blockSize arithmetic (seq * blockSize offsets) for the final partial block.","solutions":["Check disk space where the upload temp file is spooled; a truncated spool is the top cause","Retry the upload — if server-side block metadata shifted between queries, a fresh pass re-reads consistent state","Verify file size didn't change during upload (uploading a file being actively written produces length mismatches)","If reproducible at the same seq every time, inspect the groupSizes vs actual ReadAt lengths in a debug run and report the driver bug","Update the doubao_new driver — early versions had final-block sizing issues"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before merging, assert spool consistency\nif err := verifySpoolLength(tmpFile, totalSize); err != nil {\n    return fmt.Errorf(\"spool incomplete, aborting before merge: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := flushGroup(); err != nil {\n    if strings.Contains(err.Error(), \"invalid body len\") {\n        // length bookkeeping desynced: restart the upload pass\n        return d.uploadPass(ctx, ...)\n    }\n    return err\n}","preventionTips":["Free ample temp disk space before large uploads","Don't modify source files mid-upload","Keep only one upload session per file"],"tags":["doubao-new","upload","dedup","block-merge","integrity","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}