AlistGo/alist · error

cookie is empty

Error message

cookie is empty

What it means

Thrown by Yunpan360 Init() when auth_type is "cookie" (the default) and the cookie field is empty after trimming. Cookie mode scrapes the web UI (listCookiePage and friends), which requires the browser session cookie; an empty cookie means every web request would land on a login page. Note Init also forces WebProxy=true in this mode because web download URLs need browser headers.

Source

Thrown at drivers/yunpan360/driver.go:79

	d.Cookie = strings.TrimSpace(d.Cookie)
	d.APIKey = strings.TrimSpace(d.APIKey)
	d.OwnerQID = strings.TrimSpace(d.OwnerQID)
	d.DownloadToken = strings.TrimSpace(d.DownloadToken)
	d.cachedOpenAuth = nil
	d.openAuthExpire = time.Time{}
	d.cachedCookieSession = nil
	d.cookieSessionExpire = time.Time{}

	switch d.authMode() {
	case authTypeAPIKey:
		if d.APIKey == "" {
			return errors.New("api_key is empty")
		}
		_, err := d.openUserInfo(ctx)
		return err
	case authTypeCookie:
		if d.Cookie == "" {
			return errors.New("cookie is empty")
		}
		// Web download URLs require browser-session headers; force local proxying
		// so AList can forward Referer/Origin instead of exposing a bare 302 URL.
		d.WebProxy = true
		_, err := d.listCookiePage(ctx, d.RootFolderPath, 0, 1)
		return err
	default:
		return errors.New("invalid auth_type")
	}
}

func (d *Yunpan360) Drop(ctx context.Context) error {
	d.cachedOpenAuth = nil
	d.openAuthExpire = time.Time{}
	d.cachedCookieSession = nil
	d.cookieSessionExpire = time.Time{}
	return nil
}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Log in to yunpan.360.cn in a browser, copy the full Cookie header, and paste it into the cookie config field
  2. If you have an open-API key instead, set auth_type="api_key" and fill api_key
  3. Re-save the config to trigger Init() validation
Defensive patterns

Strategy: validation

Validate before calling

if cfg.AuthType == "cookie" && strings.TrimSpace(cfg.Cookie) == "" {
    return errors.New("auth_type=cookie requires a non-empty browser cookie")
}

Prevention

When it happens

Trigger: Fresh storage config left with the default auth_type=cookie but no cookie pasted; the cookie string was accidentally cleared; switching from api_key to cookie mode without providing the session cookie.

Common situations: New mount created without completing credentials; user intended api_key mode but left auth_type at default; cookie stored elsewhere (password manager) and never pasted.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/48639d15b816db83. Report an issue: GitHub.