{"record":{"id":"ab028d47f342c1ed","repo":"AlistGo/alist","slug":"if-username-or-password-is-provided-all-three-ma","errorCode":null,"errorMessage":"if username or password is provided, all three (mail_cookies, username, password) must be provided","messagePattern":"if username or password is provided, all three \\(mail_cookies, username, password\\) must be provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/139/util.go","lineNumber":1297,"sourceCode":"\td.MailCookies = strings.TrimSpace(d.MailCookies)\n\n\tif d.Authorization != \"\" {\n\t\tif strings.HasPrefix(strings.ToLower(d.Authorization), \"basic \") {\n\t\t\treturn 0, fmt.Errorf(\"authorization should not include Basic prefix\")\n\t\t}\n\t\treturn credentialStateAuthorization, nil\n\t}\n\n\tif d.MailCookies != \"\" && !hasCookiePair(d.MailCookies) {\n\t\treturn 0, fmt.Errorf(\"MailCookies format is invalid, please check your configuration\")\n\t}\n\n\thasUsername := d.Username != \"\"\n\thasPassword := strings.TrimSpace(d.Password) != \"\"\n\thasCookies := d.MailCookies != \"\"\n\tif hasUsername || hasPassword {\n\t\tif !hasUsername || !hasPassword || !hasCookies {\n\t\t\treturn 0, fmt.Errorf(\"if username or password is provided, all three (mail_cookies, username, password) must be provided\")\n\t\t}\n\t\treturn credentialStateFullLogin, nil\n\t}\n\n\tif hasCookies {\n\t\treturn credentialStateCookiesOnly, nil\n\t}\n\n\treturn 0, fmt.Errorf(\"authorization is empty and credentials are not provided\")\n}\n\nfunc (d *Yun139) tryFastLoginWithCookies() bool {\n\tsid, rmkey := extractFastLoginCookies(d.MailCookies)\n\tif sid == \"\" || rmkey == \"\" {\n\t\tlog.Warnf(\"139yun: fast login skipped, required cookies missing: Os_SSo_Sid=%t RMKEY=%t\", sid != \"\", rmkey != \"\")\n\t\treturn false\n\t}\n","sourceCodeStart":1279,"sourceCodeEnd":1315,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/139/util.go#L1279-L1315","documentation":"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.","triggerScenarios":"Configuring only username+password without mail_cookies (no captcha leg), or username+mail_cookies without password, or password alone.","commonSituations":"Users assuming password alone suffices like other cloud drivers; partially filled forms after editing an existing storage; deleting one field while debugging.","solutions":["Fill all three fields: mail_cookies, username (phone number/account), and password","If you cannot provide all three, clear username/password and use cookies-only mode with complete Os_SSo_Sid/RMKEY cookies instead","Reload the storage after saving"],"exampleFix":"# before\nusername: \"13800138000\"\npassword: \"secret\"\nmail_cookies: \"\"\n# after\nusername: \"13800138000\"\npassword: \"secret\"\nmail_cookies: \"Os_SSo_Sid=abc123; RMKEY=xyz456\"","handlingStrategy":"validation","validationCode":"// Assert the triple before enabling password login\nhasU, hasP, hasC := d.Username != \"\", strings.TrimSpace(d.Password) != \"\", d.MailCookies != \"\"\nif (hasU || hasP) && !(hasU && hasP && hasC) {\n\treturn errors.New(\"set all three: mail_cookies, username, password — or none\")\n}","typeGuard":"func isCompleteFullLogin(u, p, c string) bool {\n\treturn strings.TrimSpace(u) != \"\" && strings.TrimSpace(p) != \"\" && strings.TrimSpace(c) != \"\"\n}","tryCatchPattern":"// Convert to an actionable message at config-save time\nif err != nil && strings.Contains(err.Error(), \"all three\") {\n\treturn errors.New(\"139 full login needs mail_cookies + username + password together\")\n}","preventionTips":["Treat the three fields as one unit when editing storage config","Automate config validation in IaC pipelines so partial saves are rejected"],"tags":["config","validation","login"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}