{"record":{"id":"6b968b4f0d05320b","repo":"AlistGo/alist","slug":"init-upload-failed-s","errorCode":null,"errorMessage":"init upload failed: %s","messagePattern":"init upload failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/doubao/util.go","lineNumber":677,"sourceCode":"}\n\n// 初始化分片上传\nfunc (d *Doubao) initMultipartUpload(config *UploadConfig, uploadUrl string, storeInfo StoreInfo) (uploadId string, err error) {\n\tuploadResp := UploadResp{}\n\n\t_, err = d.uploadRequest(uploadUrl, http.MethodPost, storeInfo, func(req *resty.Request) {\n\t\treq.SetQueryParams(map[string]string{\n\t\t\t\"uploadmode\": \"part\",\n\t\t\t\"phase\":      \"init\",\n\t\t})\n\t}, &uploadResp)\n\n\tif err != nil {\n\t\treturn uploadId, err\n\t}\n\n\tif uploadResp.Code != 2000 {\n\t\treturn uploadId, fmt.Errorf(\"init upload failed: %s\", uploadResp.Message)\n\t}\n\n\treturn uploadResp.Data.UploadId, nil\n}\n\n// 分片上传实现\nfunc (d *Doubao) uploadPart(config *UploadConfig, uploadUrl, uploadID string, partNumber int64, data []byte, crc32Value string) (resp UploadPart, err error) {\n\tuploadResp := UploadResp{}\n\tstoreInfo := config.InnerUploadAddress.UploadNodes[0].StoreInfos[0]\n\n\t_, err = d.uploadRequest(uploadUrl, http.MethodPost, storeInfo, func(req *resty.Request) {\n\t\treq.SetHeaders(map[string]string{\n\t\t\t\"Content-Type\":        \"application/octet-stream\",\n\t\t\t\"Content-Crc32\":       crc32Value,\n\t\t\t\"Content-Length\":      fmt.Sprintf(\"%d\", len(data)),\n\t\t\t\"Content-Disposition\": fmt.Sprintf(\"attachment; filename=%s\", url.QueryEscape(storeInfo.StoreURI)),\n\t\t})\n","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/doubao/util.go#L659-L695","documentation":"Returned by initMultipartUpload when the Doubao upload service answered the 'uploadmode=part&phase=init' POST but with a business code other than 2000. It means the upload session could not be created: the error text is the server's message from the UploadResp envelope.","triggerScenarios":"Initializing a multipart upload where the StoreInfos auth (storeInfo.Auth header) is invalid/expired, the upload proxy URL from InnerUploadAddress is wrong or expired, upload of this file mode is disallowed for the account, or the server rejects the init parameters (bad SpaceName, ApplyId mismatch).","commonSituations":"UploadToken fetched at upload_config stage went stale before init ran, account lacks permission for the target space, the file type isn't allowed in part-upload mode, or Doubao changed init response semantics so Code is no longer 2000 on success.","solutions":["Re-fetch the upload config/token immediately before init to rule out expiry","Re-authenticate the Doubao driver to refresh UserId and authorization material","Read the server message string — it usually names the exact business reason (auth, space, mode)","Retry after a short backoff; transient 4xx-ish business codes occur under load","Check for driver updates if Doubao changed the init contract"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := d.initMultipartUpload(...); err != nil {\n    if strings.Contains(err.Error(), \"init upload failed\") {\n        // re-fetch upload config for a fresh token, then re-init once\n        cfg, _ := d.getUploadConfig(...)\n        return d.initMultipartUpload(cfg, ...)\n    }\n    return err\n}","preventionTips":["Fetch upload config immediately before init; don't cache it across long idle periods","Re-login the driver when auth-flavored init failures appear","Log the server Message string — it names the exact business reason"],"tags":["doubao","upload","api-error","multipart","init","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}