{"record":{"id":"71877e9a230e4fbd","repo":"AlistGo/alist","slug":"resp-string","errorCode":null,"errorMessage":"resp.String()","messagePattern":"resp\\.String\\(\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/cloudreve/util.go","lineNumber":62,"sourceCode":"\treq.SetHeaders(map[string]string{\n\t\t\"Cookie\":     \"cloudreve-session=\" + d.Cookie,\n\t\t\"Accept\":     \"application/json, text/plain, */*\",\n\t\t\"User-Agent\": d.getUA(),\n\t})\n\n\tvar r Resp\n\treq.SetResult(&r)\n\n\tif callback != nil {\n\t\tcallback(req)\n\t}\n\n\tresp, err := req.Execute(method, u)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !resp.IsSuccess() {\n\t\treturn errors.New(resp.String())\n\t}\n\n\tif r.Code != 0 {\n\n\t\t// 刷新 cookie\n\t\tif r.Code == http.StatusUnauthorized && path != loginPath {\n\t\t\tif d.Username != \"\" && d.Password != \"\" {\n\t\t\t\terr = d.login()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn d.request(method, path, callback, out)\n\t\t\t}\n\t\t}\n\n\t\treturn errors.New(r.Msg)\n\t}\n\tsess := cookie.GetCookie(resp.Cookies(), \"cloudreve-session\")","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/cloudreve/util.go#L44-L80","documentation":"This is the Cloudreve driver's generic HTTP failure path: the response status was not 2xx (resp.IsSuccess() false) and the error message is the raw response body. Because the body is whatever the Cloudvre server returned (HTML error page, gateway text, JSON fault), the 'message' literally shows as resp.String() content — often unstructured and not the driver's structured {code} format.","triggerScenarios":"Any Cloudvre API call (request()) where the server answers with 4xx/5xx: expired session cookie hitting a protected path, 404 from a renamed/removed route after a Cloudvre upgrade, 502/504 from an overloaded gateway, or Cloudflare challenge HTML in front of the site. Note r.Code-based cookie refresh only runs AFTER IsSuccess, so auth failures surfaced as HTTP 401 bodies land here first when the path is loginPath or the body isn't parsed.","commonSituations":"Wrong site URL or API base; Cloudvre instance behind Cloudflare/CDN returning HTML; cookie invalidated by server restart or password change; Cloudvre major version changing API routes; reverse proxy timeouts on large uploads.","solutions":["Check the raw body captured with the error — it usually names the real cause (session expired, 404, Cloudflare block)","Re-login/refresh credentials: verify username/password in the storage config; the driver re-logins on code 401 only for non-login paths, so re-save the storage to force a fresh login","Verify the site URL points directly at the Cloudvre instance (bypass CDN/challenge pages) and that its version's API routes match this driver","If a gateway 5xx, retry later or increase proxy timeouts for large transfers"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Health-check the Cloudvre endpoint before real work\nresp, err := resty.New().R().Get(siteURL)\nif err != nil || !resp.IsSuccess() {\n    return fmt.Errorf(\"cloudreve site unhealthy (status %d); check URL/proxy/CDN\", resp.StatusCode())\n}","typeGuard":null,"tryCatchPattern":"err := drv.Request(method, path, nil, &out)\nif err != nil {\n    body := err.Error() // raw server body\n    switch {\n    case strings.Contains(body, \"401\") || strings.Contains(body, \"Unauthorized\"):\n        _ = forceRelogin(drv) // re-save storage / refresh credentials\n    case strings.Contains(body, \"cloudflare\") || strings.Contains(body, \"<html\"):\n        return fmt.Errorf(\"CDN/challenge page hit; bypass it for the API host\")\n    default:\n        return retryWithBackoff(err) // transient 5xx\n    }\n}","preventionTips":["Point the storage at the Cloudvre origin, not a CDN-protected front","Keep credentials current; re-save the storage config to force re-login after password changes","After upgrading Cloudvre, verify API paths still match this driver version"],"tags":["cloudreve","http","authentication","network"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}