{"record":{"id":"1ba115eca1bd30ed","repo":"AlistGo/alist","slug":"yunpan-upload-request-failed-status-d-body-s","errorCode":null,"errorMessage":"yunpan upload request failed: status=%d body=%s","messagePattern":"yunpan upload request failed: status=(.+?) body=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/yunpan360/upload.go","lineNumber":625,"sourceCode":"\tif accessToken != \"\" {\n\t\treq.Header.Set(\"Access-Token\", accessToken)\n\t}\n\tif contentType != \"\" {\n\t\treq.Header.Set(\"Content-Type\", contentType)\n\t}\n\n\tresp, err := base.HttpClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.StatusCode >= http.StatusBadRequest {\n\t\treturn fmt.Errorf(\"yunpan upload request failed: status=%d body=%s\", resp.StatusCode, strings.TrimSpace(string(respBody)))\n\t}\n\treturn decodeUploadResp(respBody, out)\n}\n\nfunc decodeUploadResp(body []byte, out interface{}) error {\n\tvar env uploadEnvelope\n\tif err := utils.Json.Unmarshal(body, &env); err != nil {\n\t\treturn err\n\t}\n\tif env.Errno != nil && *env.Errno != 0 {\n\t\tif env.Errmsg == \"\" {\n\t\t\treturn fmt.Errorf(\"yunpan upload request failed: errno=%d\", *env.Errno)\n\t\t}\n\t\treturn errors.New(env.Errmsg)\n\t}\n\tif env.Errno == nil && strings.TrimSpace(env.Errmsg) != \"\" && len(env.Data) > 0 && string(env.Data) == \"[]\" {\n\t\treturn errors.New(env.Errmsg)\n\t}","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/yunpan360/upload.go#L607-L643","documentation":"Thrown by yunpan360's upload HTTP layer when the raw response status is >= 400 (http.StatusBadRequest). Unlike the envelope-decoded errors, this means the transport-level request itself was rejected by www.yunpan.com — auth cookie missing, URL wrong, body malformed, or server-side 5xx — with the response body included verbatim for diagnosis.","triggerScenarios":"Expired or missing Cookie header (d.Cookie empty/stale) yielding 401/403; uploading with a Content-Length mismatch yielding 400; server maintenance returning 5xx; WAF blocking the client (missing Referer/Origin headers); upload URL one-time token already consumed.","commonSituations":"Cookie-based auth where the session expired (user must re-paste cookie); long uploads where the pre-fetched upload URL expired; egress IP flagged by 360's WAF; file larger than the endpoint allows.","solutions":["Refresh the Cookie credential in driver storage and retry the upload","Log the status code: 401/403 → re-auth, 5xx → retry with backoff, 400 → inspect body for the parameter at fault","Re-acquire the upload URL/token immediately before the transfer if the flow caches it","Ensure required headers (Referer https://www.yunpan.com, Origin, X-Requested-With) are present on the request"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if strings.TrimSpace(d.Cookie) == \"\" {\n    return errors.New(\"yunpan360: cookie credential missing; update driver storage\")\n}\nif req.ContentLength < 0 {\n    return errors.New(\"yunpan360: request body length unknown; buffer file first\")\n}","typeGuard":null,"tryCatchPattern":"respBody, err := doUpload(req)\nif err != nil {\n    if strings.Contains(err.Error(), \"status=401\") || strings.Contains(err.Error(), \"status=403\") {\n        return fmt.Errorf(\"yunpan360 session invalid, update cookie: %w\", err)\n    }\n    if strings.Contains(err.Error(), \"status=5\") { // 5xx: retry with backoff\n        time.Sleep(3 * time.Second)\n        return doUpload(rebuildUploadRequest())\n    }\n    return err\n}","preventionTips":["Keep the Cookie credential fresh; probe with a cheap list call before long uploads","Always send Referer/Origin/X-Requested-With headers matching the web client","Classify by status code: 4xx auth → refresh cookie, 5xx → retry with backoff"],"tags":["yunpan360","upload","http-status","cookie-auth","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}