AlistGo/alist · error

if username or password is provided, all three (mail_cookies

Error message

if username or password is provided, all three (mail_cookies, username, password) must be provided

What it means

The 139 password-login flow needs three inputs together: mail_cookies, username, and password. credentialState() found username or password present but at least one of the other two missing, so it refuses to attempt a login that would fail halfway.

Source

Thrown at drivers/139/util.go:1297

	d.MailCookies = strings.TrimSpace(d.MailCookies)

	if d.Authorization != "" {
		if strings.HasPrefix(strings.ToLower(d.Authorization), "basic ") {
			return 0, fmt.Errorf("authorization should not include Basic prefix")
		}
		return credentialStateAuthorization, nil
	}

	if d.MailCookies != "" && !hasCookiePair(d.MailCookies) {
		return 0, fmt.Errorf("MailCookies format is invalid, please check your configuration")
	}

	hasUsername := d.Username != ""
	hasPassword := strings.TrimSpace(d.Password) != ""
	hasCookies := d.MailCookies != ""
	if hasUsername || hasPassword {
		if !hasUsername || !hasPassword || !hasCookies {
			return 0, fmt.Errorf("if username or password is provided, all three (mail_cookies, username, password) must be provided")
		}
		return credentialStateFullLogin, nil
	}

	if hasCookies {
		return credentialStateCookiesOnly, nil
	}

	return 0, fmt.Errorf("authorization is empty and credentials are not provided")
}

func (d *Yun139) tryFastLoginWithCookies() bool {
	sid, rmkey := extractFastLoginCookies(d.MailCookies)
	if sid == "" || rmkey == "" {
		log.Warnf("139yun: fast login skipped, required cookies missing: Os_SSo_Sid=%t RMKEY=%t", sid != "", rmkey != "")
		return false
	}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Fill all three fields: mail_cookies, username (phone number/account), and password
  2. If you cannot provide all three, clear username/password and use cookies-only mode with complete Os_SSo_Sid/RMKEY cookies instead
  3. Reload the storage after saving

Example fix

# before
username: "13800138000"
password: "secret"
mail_cookies: ""
# after
username: "13800138000"
password: "secret"
mail_cookies: "Os_SSo_Sid=abc123; RMKEY=xyz456"
Defensive patterns

Strategy: validation

Validate before calling

// Assert the triple before enabling password login
hasU, hasP, hasC := d.Username != "", strings.TrimSpace(d.Password) != "", d.MailCookies != ""
if (hasU || hasP) && !(hasU && hasP && hasC) {
	return errors.New("set all three: mail_cookies, username, password — or none")
}

Type guard

func isCompleteFullLogin(u, p, c string) bool {
	return strings.TrimSpace(u) != "" && strings.TrimSpace(p) != "" && strings.TrimSpace(c) != ""
}

Try / catch

// Convert to an actionable message at config-save time
if err != nil && strings.Contains(err.Error(), "all three") {
	return errors.New("139 full login needs mail_cookies + username + password together")
}

Prevention

When it happens

Trigger: Configuring only username+password without mail_cookies (no captcha leg), or username+mail_cookies without password, or password alone.

Common situations: Users assuming password alone suffices like other cloud drivers; partially filled forms after editing an existing storage; deleting one field while debugging.

Related errors


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