{"record":{"id":"39af66f03cb45f1b","repo":"AlistGo/alist","slug":"upload-failed-after-d-retries-due-to-server-error-39af66","errorCode":null,"errorMessage":"upload failed after %d retries due to server errors, error: %s","messagePattern":"upload failed after (.+?) retries due to server errors, error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/cloudreve_v4/util.go","lineNumber":317,"sourceCode":"\t\t\tvar up Resp\n\t\t\terr = json.Unmarshal(body, &up)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif up.Code != 0 {\n\t\t\t\treturn errors.New(up.Msg)\n\t\t\t}\n\t\t\treturn nil\n\t\t}()\n\t\tif err == nil {\n\t\t\tretryCount = 0\n\t\t\tfinish += byteSize\n\t\t\tup(float64(finish) * 100 / float64(file.GetSize()))\n\t\t\tchunk++\n\t\t} else {\n\t\t\tretryCount++\n\t\t\tif retryCount > maxRetries {\n\t\t\t\treturn fmt.Errorf(\"upload failed after %d retries due to server errors, error: %s\", maxRetries, err)\n\t\t\t}\n\t\t\tbackoff := time.Duration(1<<retryCount) * time.Second\n\t\t\tutils.Log.Warnf(\"[Cloudreve-Remote] server errors while uploading, retrying after %v...\", backoff)\n\t\t\ttime.Sleep(backoff)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (d *CloudreveV4) upOneDrive(ctx context.Context, file model.FileStreamer, u FileUploadResp, up driver.UpdateProgress) error {\n\tuploadUrl := u.UploadUrls[0]\n\tvar finish int64 = 0\n\tDEFAULT := int64(u.ChunkSize)\n\tretryCount := 0\n\tmaxRetries := 3\n\tfor finish < file.GetSize() {\n\t\tif utils.IsCanceled(ctx) {\n\t\t\treturn ctx.Err()","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/cloudreve_v4/util.go#L299-L335","documentation":"Fatal retry exhaustion in Cloudreve v4's remote-protocol chunked upload (upRemote). Chunks are POSTed through the Cloudreve server with exponential backoff on error; after maxRetries consecutive failures the upload aborts with this message embedding the last error (often the server's error payload).","triggerScenarios":"A Cloudreve v4 upload session where each chunk request errors maxRetries+1 times consecutively — server 5xx, server-side storage policy failure (its OneDrive/S3 backing down), quota exhaustion, or an expired upload session returning errors per chunk.","commonSituations":"Cloudreve v4 server's storage policy unhealthy; server disk full; large uploads over unstable links where every retry fails; version mismatch between client expectations and the v4 API session lifecycle.","solutions":["Inspect the embedded server error and the Cloudreve v4 server logs to find the failing step","Restore the server's storage policy health / free disk space, then re-upload","Restart the upload to obtain a fresh session if the old one expired","Use smaller chunks or retry later when the server is stable"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-flight: confirm session and upload URLs are present\nif u.SessionID == \"\" || len(u.UploadUrls) == 0 {\n    return errors.New(\"invalid v4 upload session; request a new one\")\n}","typeGuard":null,"tryCatchPattern":"if err := d.upRemote(ctx, file, u, up); err != nil {\n    if strings.Contains(err.Error(), \"upload failed after\") {\n        time.Sleep(2 * time.Minute)\n        // one full restart with a fresh session, then report\n    }\n}","preventionTips":["Check Cloudreve v4 server and its storage policy health before large uploads","Restart uploads with fresh sessions after exhaustion instead of hammering retries","Track per-server failure rates and back off degraded instances"],"tags":["alist","cloudreve-v4","upload","retry","server-error"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}