AlistGo/alist · critical

bad cid: %s, body: %s

Error message

bad cid: %s, body: %s

What it means

Returned by HalalCloud after downloading (and XOR-decrypting, when Encrypt > 0) a slice: the CID recomputed from the bytes does not equal the CID stored in addr.Identity. This is content-integrity failure — the bytes on the wire do not match what the provider committed to, indicating corruption or wrong decryption. Skipped entirely for StoreType == 10 (raw storage).

Source

Thrown at drivers/halalcloud/util.go:261

	if addr.Encrypt > 0 {
		cd := uint8(addr.Encrypt)
		for idx := 0; idx < len(body); idx++ {
			body[idx] = body[idx] ^ cd
		}
	}

	if addr.StoreType != 10 {

		sourceCid, err := cid.Decode(addr.Identity)
		if err != nil {
			return nil, err
		}
		checkCid, err := sourceCid.Prefix().Sum(body)
		if err != nil {
			return nil, err
		}
		if !checkCid.Equals(sourceCid) {
			return nil, fmt.Errorf("bad cid: %s, body: %s", checkCid.String(), body)
		}
	}

	return body, nil

}

type openObject struct {
	ctx     context.Context
	mu      sync.Mutex
	d       []*pubUserFile.SliceDownloadInfo
	id      int
	skip    int64
	chunk   *[]byte
	chunks  *[]chunkSize
	closed  bool
	sha     string
	shaTemp hash.Hash

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Re-fetch the download address for the slice and download again — transient corruption is the most common cause.
  2. Bypass HTTP proxies/middleboxes for these requests and retry; injected HTML error pages are a classic cause.
  3. If it reproduces for the same slice every time, the stored object itself is corrupt server-side — re-upload the file.
  4. Check the driver is current in case the Encrypt scheme changed.
Defensive patterns

Strategy: retry

Try / catch

body, err := fetchAndVerify(client, addr)
if err != nil && strings.Contains(err.Error(), "bad cid") {
    body, err = fetchAndVerify(client, addr) // one retry, no proxy
    if err != nil { return fmt.Errorf("slice corrupt after retry: %w", err) }
}

Prevention

When it happens

Trigger: Encrypt value wrong/stale so the XOR 'decryption' produces garbage (correct-length but wrong bytes); a corrupted storage node; a truncated or tampered response (proxy, captive portal injecting bytes); CID field parsed incorrectly.

Common situations: Caching proxy mangling slice responses; driver version mismatch with the provider's encryption scheme; rare bit-rot on the provider's storage; address metadata fetched for a different file/slice.

Related errors


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