{"record":{"id":"e9ab2f70ec4ef204","repo":"AlistGo/alist","slug":"wukong-upload-to-tos-crc32-mismatch-local-s-remo","errorCode":null,"errorMessage":"wukong upload to tos crc32 mismatch: local=%s remote=%s","messagePattern":"wukong upload to tos crc32 mismatch: local=(.+?) remote=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"drivers/wukong/driver.go","lineNumber":592,"sourceCode":"\t\tSetHeader(\"Authorization\", auth).\n\t\tSetHeader(\"Content-Type\", \"application/octet-stream\").\n\t\tSetHeader(\"Content-Crc32\", crc32Hex).\n\t\tSetHeader(\"Content-Disposition\", fmt.Sprintf(`attachment; filename=\"%s\"`, url.QueryEscape(fileName))).\n\t\tSetHeader(\"Content-Length\", strconv.FormatInt(size, 10)).\n\t\tSetBody(body).\n\t\tSetResult(&resp)\n\tif storageUser != \"\" {\n\t\treq.SetHeader(\"X-Storage-U\", storageUser)\n\t}\n\t_, err := req.Post(uploadURL)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.Code != minUploadSubmitSuccess {\n\t\treturn fmt.Errorf(\"wukong upload to tos failed: code=%d message=%s\", resp.Code, resp.Message)\n\t}\n\tif resp.Data.Crc32 != \"\" && !strings.EqualFold(resp.Data.Crc32, crc32Hex) {\n\t\treturn fmt.Errorf(\"wukong upload to tos crc32 mismatch: local=%s remote=%s\", crc32Hex, resp.Data.Crc32)\n\t}\n\treturn nil\n}\n\nfunc (d *Wukong) uploadToTOSMultipart(ctx context.Context, host, storeURI, auth, storageUser string, tempFile model.File, size int64, up driver.UpdateProgress) error {\n\tuploadID, err := d.initMultipartUpload(ctx, host, storeURI, auth, storageUser)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttotalParts := int((size + multipartChunkSize - 1) / multipartChunkSize)\n\tif totalParts <= 0 {\n\t\treturn errors.New(\"invalid multipart parts\")\n\t}\n\tparts := make([]string, 0, totalParts)\n\tfor i := 0; i < totalParts; i++ {\n\t\tpartNumber := i + 1\n\t\toffset := int64(i) * multipartChunkSize","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/wukong/driver.go#L574-L610","documentation":"Thrown by uploadToTOS when the TOS endpoint returns a Crc32 that does not match the locally computed IEEE CRC32 of the uploaded body. The server is explicitly reporting that the bytes it stored differ from the bytes sent — a data-integrity failure detected end-to-end.","triggerScenarios":"Client-side body corruption (truncated temp file, concurrent write to the cached temp file); transparent modification by a proxy/AV scanning middlebox; server-side bug returning the wrong CRC; memory/disk corruption on the host.","commonSituations":"CacheFullInTempFile raced with another writer; flaky NIC or disk producing bit errors; corporate proxy re-encoding the body; rare server-side mismatch after retries.","solutions":["Retry the upload from a freshly cached temp file (re-run CacheFullInTempFile) with a new upload session","Verify local file integrity (compare md5 before upload) to rule out source corruption","Bypass intermediaries (proxy, AV TLS inspection) that could mutate the body","If persistent for one environment but not others, capture the sent body hash server-side and report upstream"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify local integrity before upload\nh := crc32.NewIEEE()\nif f, ok := tempFile.(io.Reader); ok {\n    io.Copy(h, f) // tempFile must support re-read; else use stored hash\n}\nlocalCRC := fmt.Sprintf(\"%08x\", h.Sum32())","typeGuard":null,"tryCatchPattern":"if err := d.uploadToTOS(...); err != nil {\n    if strings.Contains(err.Error(), \"crc32 mismatch\") {\n        // data corrupted in transit/cache: full clean retry with fresh session\n        return d.restartAndUpload(ctx)\n    }\n    return err\n}","preventionTips":["Never let anything write the temp cache file while uploading","Compare md5 of source vs cached temp file before transfer","Treat CRC mismatches as corruption events — never ignore or continue past them"],"tags":["wukong","upload","tos","crc32","integrity","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}