{"record":{"id":"f29f483dfafab6d3","repo":"AlistGo/alist","slug":"captcha-type-s-not-support","errorCode":null,"errorMessage":"captcha type %s not support","messagePattern":"captcha type (.+?) not support","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/cloudreve_v4/util.go","lineNumber":137,"sourceCode":"\t\t}\n\t}\n\treturn err\n}\n\nfunc (d *CloudreveV4) doLogin(needCaptcha bool) error {\n\tvar err error\n\tloginBody := base.Json{\n\t\t\"email\":    d.Username,\n\t\t\"password\": d.Password,\n\t}\n\tif needCaptcha {\n\t\tvar config BasicConfigResp\n\t\terr = d.request(http.MethodGet, \"/site/config/basic\", nil, &config)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif config.CaptchaType != \"normal\" {\n\t\t\treturn fmt.Errorf(\"captcha type %s not support\", config.CaptchaType)\n\t\t}\n\t\tvar captcha CaptchaResp\n\t\terr = d.request(http.MethodGet, \"/site/captcha\", nil, &captcha)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !strings.HasPrefix(captcha.Image, \"data:image/png;base64,\") {\n\t\t\treturn errors.New(\"can not get captcha\")\n\t\t}\n\t\tloginBody[\"ticket\"] = captcha.Ticket\n\t\ti := strings.Index(captcha.Image, \",\")\n\t\tdec := base64.NewDecoder(base64.StdEncoding, strings.NewReader(captcha.Image[i+1:]))\n\t\tvRes, err := base.RestyClient.R().SetMultipartField(\n\t\t\t\"image\", \"validateCode.png\", \"image/png\", dec).\n\t\t\tPost(setting.GetStr(conf.OcrApi))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/cloudreve_v4/util.go#L119-L155","documentation":"Thrown during Cloudreve v4 login when the site requires a captcha. The driver fetches /site/config/basic; only the built-in \"normal\" (base64 PNG image) captcha is implemented — any other captcha_type (e.g. recaptcha, turnstile, or a plugin captcha) cannot be solved programmatically, so login aborts before requesting a ticket.","triggerScenarios":"Calling login() against a Cloudreve v4 instance whose admin enabled a non-normal captcha (Cloudflare Turnstile, reCAPTCHA, or a custom captcha provider) while the driver's needCaptcha path is active (no valid session/refresh token yet).","commonSituations":"Site owner hardens the Cloudreve login with Turnstile after the alist storage was configured; the stored token expired, forcing re-login through the captcha path; targeting a Cloudreve v4 instance with a captcha plugin installed.","solutions":["In Cloudreve v4 admin settings, switch the captcha to the built-in normal image captcha (or disable captcha) so the driver can fetch and solve it","Prefer API-token/session-based auth (provide a valid refresh/ access token) so login with captcha is never triggered","Keep the session alive by refreshing tokens before they expire, avoiding the login path entirely"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-flight: check the site's captcha mode before attempting silent login\nvar config BasicConfigResp\nif err := d.request(http.MethodGet, \"/site/config/basic\", nil, &config); err == nil {\n    if config.CaptchaType != \"\" && config.CaptchaType != \"normal\" {\n        return fmt.Errorf(\"site requires unsupported captcha %q; use token auth instead\", config.CaptchaType)\n    }\n}","typeGuard":"func captchaSolvable(t string) bool { return t == \"\" || t == \"normal\" }","tryCatchPattern":"if err := d.login(); err != nil {\n    if strings.Contains(err.Error(), \"captcha type\") {\n        // no automated fix: instruct user to change captcha or provide a token; do not retry\n        return err\n    }\n}","preventionTips":["Configure Cloudreve v4 with the normal image captcha (or none) when used with alist","Supply long-lived tokens so the login path is never exercised","Monitor token expiry and refresh before re-login is required"],"tags":["alist","cloudreve-v4","captcha","login","unsupported"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}