{"record":{"id":"d95e80b2fa86f05d","repo":"AlistGo/alist","slug":"resp-string-d95e80","errorCode":null,"errorMessage":"resp.String()","messagePattern":"resp\\.String\\(\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/cloudreve_v4/util.go","lineNumber":62,"sourceCode":"\t\t\"User-Agent\": d.getUA(),\n\t})\n\tif d.AccessToken != \"\" {\n\t\treq.SetHeader(\"Authorization\", \"Bearer \"+d.AccessToken)\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\t\tif r.Code == 401 && d.RefreshToken != \"\" && path != \"/session/token/refresh\" {\n\t\t\t// try to refresh token\n\t\t\terr = d.refreshToken()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn d.request(method, path, callback, out)\n\t\t}\n\t\treturn errors.New(r.Msg)\n\t}\n\n\tif out != nil && r.Data != nil {\n\t\tvar marshal []byte\n\t\tmarshal, err = json.Marshal(r.Data)\n\t\tif err != nil {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/cloudreve_v4/util.go#L44-L80","documentation":"CloudreveV4 request helper returns this when the HTTP response status is not 2xx, before any JSON envelope parsing. resp.String() dumps the whole response body — often an HTML error page from a reverse proxy, a 404 from a wrong base URL, or a gateway timeout page.","triggerScenarios":"req.Execute(method, u) completes but resp.IsSuccess() is false. Caused by wrong site address in the driver addition, Cloudrebve V4 not actually running V4 API routes, 5xx from upstream, or auth middleware rejecting with non-JSON.","commonSituations":"Driver pointed at a Cloudrebve V3 instance (different API paths) while using the V4 driver; trailing path/scheme mistakes in the address field; reverse proxy returning 502/504 HTML; maintenance mode enabled on the site.","solutions":["Confirm the address points to a real Cloudreve V4 instance (check /api/v4/site/config/login responds).","Fix scheme/host/port in the storage addition; avoid trailing slash or path suffixes unless required.","If a reverse proxy fronts the instance, ensure it forwards to the correct upstream and does not intercept API routes.","Read the body inside the error — it identifies whether the failure is from Cloudrebve, the proxy, or a CDN."],"exampleFix":"# before: address = https://demo.cloudreve.org (V3 site)\n# after:  address = https://v4.example.com   (actual Cloudreve V4 deployment)\ncurl -sS https://v4.example.com/api/v4/site/config/login","handlingStrategy":"validation","validationCode":"// verify the base URL is a live CloudreveV4 API before any storage op\nprobe, err := http.NewRequest(http.MethodGet, address+\"/api/v4/site/config/login\", nil)\nif err != nil { return err }\nres, err := base.HttpClient.Do(probe)\nif err != nil || res.StatusCode != 200 { return errors.New(\"address is not a Cloudreve V4 endpoint\") }","typeGuard":"func isHttpFailure(err error) bool {\n    return err != nil && (strings.Contains(err.Error(), \"404\") || strings.Contains(err.Error(), \"502\") || strings.Contains(err.Error(), \"<html\"))\n}","tryCatchPattern":"if err := d.request(...); err != nil {\n    if strings.Contains(err.Error(), \"<html\") { // proxy error page, not API JSON\n        return fmt.Errorf(\"non-JSON response from %s — check address/reverse proxy: %w\", d.Address, err)\n    }\n    return err\n}","preventionTips":["Point the driver only at true Cloudreve V4 deployments","Health-check the /api/v4 base path at storage-save time","Keep reverse proxy error pages from masking API responses"],"tags":["cloudreve-v4","http-status","configuration","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}