AlistGo/alist · error

[doubao_new] upload v3 block invalid seq

Error message

[doubao_new] upload v3 block invalid seq

What it means

uploadBlockV3 rejects a negative block.Seq, since the block sequence number is used for the x-block-seq header and ordering on the server. In stock code seqs are loop indices and cannot be negative; the guard protects custom callers and deserialized block metadata.

Source

Thrown at drivers/doubao_new/util.go:824

			}
			return UploadMergeData{SuccessSeqList: success}, nil
		}
		errMsg := resp.Msg
		if errMsg == "" {
			errMsg = resp.Message
		}
		return UploadMergeData{}, fmt.Errorf("[doubao_new] API error (code: %d): %s", resp.Code, errMsg)
	}

	return resp.Data, nil
}

func (d *DoubaoNew) uploadBlockV3(ctx context.Context, uploadID string, block UploadBlockNeed, data []byte) error {
	if uploadID == "" {
		return fmt.Errorf("[doubao_new] upload v3 block missing upload_id")
	}
	if block.Seq < 0 {
		return fmt.Errorf("[doubao_new] upload v3 block invalid seq")
	}
	if len(data) == 0 {
		return fmt.Errorf("[doubao_new] upload v3 block empty data")
	}

	req := base.RestyClient.R()
	req.SetContext(ctx)
	req.SetHeader("accept", "*/*")
	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("x-block-seq", strconv.Itoa(block.Seq))
	req.SetHeader("x-block-checksum", block.Checksum)
	if auth := d.resolveAuthorization(); auth != "" {
		req.SetHeader("authorization", auth)
	}
	if dpop := d.resolveDpop(); dpop != "" {

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Validate seq >= 0 when building the block list, not at upload time.
  2. If loading block metadata from persistence, reject rows with negative seq at load time.
  3. Re-run prepare to get a fresh, internally consistent block plan.

Example fix

// before
block := UploadBlockNeed{Seq: seqFromFile}

// after
if seqFromFile < 0 {
    return fmt.Errorf("invalid block seq %d", seqFromFile)
}
block := UploadBlockNeed{Seq: seqFromFile}
Defensive patterns

Strategy: validation

Validate before calling

for _, b := range blocks {
    if b.Seq < 0 { return fmt.Errorf("invalid block seq %d", b.Seq) }
}

Prevention

When it happens

Trigger: Calling uploadBlockV3 with block metadata parsed from external input where Seq was absent (defaulting to -1 sentinel) or mis-parsed with a sign; corrupted block lists after a refactor.

Common situations: Custom integrations storing UploadBlockNeed as JSON and reloading with schema drift; sentinel values (-1) leaking into the upload path.

Related errors


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