{"record":{"id":"3bbe9408486d8894","repo":"AlistGo/alist","slug":"wukong-init-multipart-upload-failed-code-d-messa","errorCode":null,"errorMessage":"wukong init multipart upload failed: code=%d message=%s","messagePattern":"wukong init multipart upload failed: code=(.+?) message=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/wukong/driver.go","lineNumber":658,"sourceCode":"\t\tSetHeader(\"Host\", host).\n\t\tSetHeader(\"Referer\", webReferer).\n\t\tSetHeader(\"Origin\", \"https://pan.wkbrowser.com\").\n\t\tSetHeader(\"Authorization\", auth).\n\t\tSetQueryParams(map[string]string{\n\t\t\t\"uploadmode\": \"part\",\n\t\t\t\"phase\":      \"init\",\n\t\t}).\n\t\tSetResult(&resp)\n\tif storageUser != \"\" {\n\t\treq.SetHeader(\"X-Storage-U\", storageUser)\n\t}\n\tuploadURL := fmt.Sprintf(\"https://%s/upload/v1/%s\", host, storeURI)\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 init multipart upload failed: code=%d message=%s\", resp.Code, resp.Message)\n\t}\n\tif resp.Data.UploadID == \"\" {\n\t\treturn \"\", errors.New(\"wukong init multipart upload returns empty uploadid\")\n\t}\n\treturn resp.Data.UploadID, nil\n}\n\nfunc (d *Wukong) uploadMultipartPart(ctx context.Context, host, storeURI, auth, storageUser, uploadID string, partNumber int, data []byte, crc32Hex string) (string, error) {\n\tvar resp tosUploadResp\n\treq := base.NewRestyClient().R().\n\t\tSetContext(ctx).\n\t\tSetHeader(\"Host\", host).\n\t\tSetHeader(\"Referer\", webReferer).\n\t\tSetHeader(\"Origin\", \"https://pan.wkbrowser.com\").\n\t\tSetHeader(\"Authorization\", auth).\n\t\tSetHeader(\"Content-Type\", \"application/octet-stream\").\n\t\tSetHeader(\"Content-Crc32\", crc32Hex).\n\t\tSetHeader(\"Content-Length\", strconv.Itoa(len(data))).","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/wukong/driver.go#L640-L676","documentation":"Thrown by initMultipartUpload when POSTing phase=init to https://<host>/upload/v1/<storeURI> returns a code other than 2000. The TOS multipart session could not be created, so no UploadID exists and the whole multipart transfer aborts before any part is sent.","triggerScenarios":"Authorization from ApplyUploadInner expired or not valid for multipart; storeURI malformed; selected upload host rejecting the init; X-Storage-U required but missing; upstream TOS outage.","commonSituations":"Upload started long after applyUploadInner (token TTL passed); best-host list stale; a previous upload's auth being reused after a driver retry.","solutions":["Re-run applyUploadInner to obtain fresh StoreURI, hosts, and Authorization, then init again","Verify resp handles the empty-UploadID guard: if code is 2000 but UploadID is empty, that is a separate error — report upstream","Retry against a different host from the candidates list","Check that the file size actually requires multipart (totalParts > 0) before initializing"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if size <= 0 {\n    return errors.New(\"multipart init aborted: non-positive file size\")\n}","typeGuard":null,"tryCatchPattern":"uploadID, err := d.initMultipartUpload(ctx, host, storeURI, auth, storageUser)\nif err != nil {\n    if strings.Contains(err.Error(), \"auth\") || strings.Contains(err.Error(), \"expire\") {\n        // fresh apply + init once\n        return d.restartMultipart(ctx, tempFile, size)\n    }\n    return err\n}","preventionTips":["Init multipart immediately after applyUploadInner while auth is fresh","Do not reuse StoreURI/auth across retries of the whole upload","Handle the separate empty-UploadID error distinctly for clearer diagnostics"],"tags":["wukong","upload","multipart","tos","init","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}