{"record":{"id":"227d40b83f86e07c","repo":"AlistGo/alist","slug":"mailcookies-format-is-invalid-please-check-your-c","errorCode":null,"errorMessage":"MailCookies format is invalid, please check your configuration","messagePattern":"MailCookies format is invalid, please check your configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/139/util.go","lineNumber":1289,"sourceCode":"\tdefault:\n\t\treturn fmt.Errorf(\"unsupported credential state: %d\", state)\n\t}\n}\n\nfunc (d *Yun139) credentialState() (credentialState, error) {\n\td.Authorization = strings.TrimSpace(d.Authorization)\n\td.Username = strings.TrimSpace(d.Username)\n\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}","sourceCodeStart":1271,"sourceCodeEnd":1307,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/139/util.go#L1271-L1307","documentation":"MailCookies is non-empty but hasCookiePair() found no valid 'key=value' pair in it. The driver requires the cookie string to contain at least one k=v pair (in practice Os_SSo_Sid and RMKEY); free text, a bare session id, or a JSON blob fails this check.","triggerScenarios":"Pasting only the RMKEY value without the 'Os_SSo_Sid=...' key part, pasting a whole 'Cookie:' header line including the header name, or pasting whitespace/format artifacts so no '=' survives parsing.","commonSituations":"Users new to cookie extraction copying the wrong devtools column ('Value' only instead of full 'name=value'), or concatenating cookies with newlines/commas instead of '; '.","solutions":["Re-copy cookies as 'Os_SSo_Sid=<val>; RMKEY=<val>' — name=value pairs joined by '; '","In browser devtools use the 'Cookies' table and copy both name and value columns, or use 'Copy value' on the whole Cookie request header then strip the 'Cookie: ' prefix","Save and reload the storage after fixing"],"exampleFix":"# before\nmail_cookies: \"abc123sessionidvalueonly\"\n# after\nmail_cookies: \"Os_SSo_Sid=abc123; RMKEY=xyz456\"","handlingStrategy":"validation","validationCode":"// Reuse the driver's own predicate before init\nif d.MailCookies != \"\" && !hasCookiePair(d.MailCookies) {\n\treturn errors.New(\"mail_cookies must look like 'name=value; name2=value2'\")\n}","typeGuard":"func looksLikeCookieHeader(s string) bool {\n\ts = strings.TrimSpace(s)\n\tif strings.HasPrefix(strings.ToLower(s), \"cookie:\") { return false }\n\tfor _, part := range strings.Split(s, \";\") {\n\t\tif strings.Contains(strings.TrimSpace(part), \"=\") { return true }\n\t}\n\treturn false\n}","tryCatchPattern":"// Fail fast with a config hint\nif err != nil && strings.Contains(err.Error(), \"MailCookies format is invalid\") {\n\treturn errors.New(\"re-copy cookies as 'Os_SSo_Sid=...; RMKEY=...'\")\n}","preventionTips":["Copy the full cookie header value (minus 'Cookie:' prefix) from a logged-in browser session","Never paste only cookie values without names","Validate cookie strings in your provisioning scripts with the same pair check"],"tags":["config","validation","cookies"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}