AlistGo/alist · error
can not get captcha
Error message
can not get captcha
What it means
Thrown by Cloudreve doLogin when the site requires a captcha for login, the GET /site/captcha call technically succeeded, but the returned captcha string is empty. Without a captcha image the driver cannot OCR it, so login aborts before ever sending credentials.
Source
Thrown at drivers/cloudreve/util.go:127
}
if err.Error() != "CAPTCHA not match." {
break
}
}
return err
}
func (d *Cloudreve) doLogin(needCaptcha bool) error {
var captchaCode string
var err error
if needCaptcha {
var captcha string
err = d.request(http.MethodGet, "/site/captcha", nil, &captcha)
if err != nil {
return err
}
if len(captcha) == 0 {
return errors.New("can not get captcha")
}
i := strings.Index(captcha, ",")
dec := base64.NewDecoder(base64.StdEncoding, strings.NewReader(captcha[i+1:]))
vRes, err := base.RestyClient.R().SetMultipartField(
"image", "validateCode.png", "image/png", dec).
Post(setting.GetStr(conf.OcrApi))
if err != nil {
return err
}
if jsoniter.Get(vRes.Body(), "status").ToInt() != 200 {
return errors.New("ocr error:" + jsoniter.Get(vRes.Body(), "msg").ToString())
}
captchaCode = jsoniter.Get(vRes.Body(), "result").ToString()
}
var resp Resp
err = d.request(http.MethodPost, loginPath, func(req *resty.Request) {
req.SetBody(base.Json{
"username": d.Addition.Username,View on GitHub (pinned to 843d9dc814)
Solutions
- Retry the operation after a few seconds — captcha generation can be transiently unavailable or rate-limited.
- Disable login captcha in Cloudreve admin panel (Settings -> Login) if API mounting is intended, removing the dependency entirely.
- Verify GET /site/captcha directly with curl/cookies to confirm the server returns a non-empty base64 image.
- Upgrade the driver/repo — newer Cloudrebve builds tie captcha to a ticket; make sure your server and driver versions match.
Defensive patterns
Strategy: retry
Try / catch
for range 3 {
err = d.doLogin(true)
if err == nil || err.Error() != "can not get captcha" {
break
}
time.Sleep(2 * time.Second) // captcha endpoint may be transiently empty
} Prevention
- Disable login captcha in Cloudrebve admin for API mounts
- Avoid tight login retry loops that exhaust captcha generation
- Verify /site/captcha returns a non-empty body before automating logins
When it happens
Trigger: Cloudreve has login captcha enabled; doLogin(needCaptcha=true) calls GET /site/captcha; the response decodes to an empty string (server-side captcha generation failure, rate limiting, or an error envelope that was silently unmarshalled to empty).
Common situations: Cloudrebve version change where /site/captcha only issues a captcha per session/ticket that was already consumed; login attempts hammered in a loop consuming the captcha; reverse proxy stripping the response; guest login forced by an unconfigured site.
Related errors
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/75599767f95c5d94.
Report an issue: GitHub.