{"record":{"id":"9658e84dcd49db0b","repo":"AlistGo/alist","slug":"string-data","errorCode":null,"errorMessage":"string(data)","messagePattern":"string\\(data\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/cloudreve/util.go","lineNumber":356,"sourceCode":"\t\tres, err := base.HttpClient.Do(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// https://learn.microsoft.com/zh-cn/onedrive/developer/rest-api/api/driveitem_createuploadsession\n\t\tswitch {\n\t\tcase res.StatusCode >= 500 && res.StatusCode <= 504:\n\t\t\tretryCount++\n\t\t\tif retryCount > maxRetries {\n\t\t\t\tres.Body.Close()\n\t\t\t\treturn fmt.Errorf(\"upload failed after %d retries due to server errors, error %d\", maxRetries, res.StatusCode)\n\t\t\t}\n\t\t\tbackoff := time.Duration(1<<retryCount) * time.Second\n\t\t\tutils.Log.Warnf(\"[Cloudreve-OneDrive] server errors %d while uploading, retrying after %v...\", res.StatusCode, backoff)\n\t\t\ttime.Sleep(backoff)\n\t\tcase res.StatusCode != 201 && res.StatusCode != 202 && res.StatusCode != 200:\n\t\t\tdata, _ := io.ReadAll(res.Body)\n\t\t\tres.Body.Close()\n\t\t\treturn errors.New(string(data))\n\t\tdefault:\n\t\t\tres.Body.Close()\n\t\t\tretryCount = 0\n\t\t\tfinish += byteSize\n\t\t\tup(float64(finish) * 100 / float64(stream.GetSize()))\n\t\t}\n\t}\n\t// 上传成功发送回调请求\n\treturn d.request(http.MethodPost, \"/callback/onedrive/finish/\"+u.SessionID, func(req *resty.Request) {\n\t\treq.SetBody(\"{}\")\n\t}, nil)\n}\n\nfunc (d *Cloudreve) upS3(ctx context.Context, stream model.FileStreamer, u UploadInfo, up driver.UpdateProgress) error {\n\tvar finish int64 = 0\n\tvar chunk int = 0\n\tvar etags []string\n\tDEFAULT := int64(u.ChunkSize)","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/cloudreve/util.go#L338-L374","documentation":"During Cloudreve OneDrive-policy upload, a chunk/callback HTTP response had a status outside {200, 201, 202} and the raw body is returned as the error text. The body is usually the server's or Microsoft Graph's error JSON/HTML, shown verbatim.","triggerScenarios":"upOneDrive loop: after PUTting a chunk to the OneDrive upload URL (or when a proxy answers), res.StatusCode is e.g. 416/409/429 (not 5xx, which would retry). The body is read and returned untouched.","commonSituations":"Chunk offsets out of range for the session (416 Requested Range Not Satisfiable) after a resume; OneDrive upload URL expired (sessions live ~15 minutes); 429 throttling without Retry-After being honored; corporate proxy returning an HTML error page.","solutions":["Retry the upload as a new OneDrive session — expired upload URLs and stale ranges are the dominant cause.","For 429 responses, wait and retry later; OneDrive throttles aggressive chunk uploads.","Increase chunk size or reduce parallelism so the session completes within its lifetime.","Read the returned body — it usually contains Graph's code/message pinpointing the exact failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isGraphErrorBody(body string) bool {\n    return strings.Contains(body, \"\\\"error\\\"\") || strings.Contains(body, \"service_unavailable\")\n}","tryCatchPattern":"data, _ := io.ReadAll(res.Body)\nif res.StatusCode != 200 && res.StatusCode != 201 && res.StatusCode != 202 {\n    var g struct{ Error struct{ Code, Message string } }\n    if json.Unmarshal(data, &g) == nil && g.Error.Code != \"\" {\n        return fmt.Errorf(\"onedrive upload %s: %s\", g.Error.Code, g.Error.Message)\n    }\n    return errors.New(string(data))\n}","preventionTips":["Finish OneDrive upload sessions within their ~15-minute lifetime","Honor 429 Retry-After instead of hammering","Parse Graph error JSON from the body before surfacing raw text"],"tags":["cloudreve","onedrive","upload","http-status","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}