{"record":{"id":"32f968ac94bb9ada","repo":"AlistGo/alist","slug":"empty-session-token-received","errorCode":null,"errorMessage":"empty session token received","messagePattern":"empty session token received","errorType":"http","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"drivers/mediafire/util.go","lineNumber":84,"sourceCode":"\t\treturn \"\", err\n\t}\n\n\t//fmt.Printf(\"getSessionToken :: Raw response: %s\\n\", string(body))\n\t//fmt.Printf(\"getSessionToken :: Parsed response: %+v\\n\", resp)\n\n\tvar tokenResp struct {\n\t\tResponse struct {\n\t\t\tSessionToken string `json:\"session_token\"`\n\t\t} `json:\"response\"`\n\t}\n\n\tif resp.StatusCode == 200 {\n\t\tif err := json.Unmarshal(body, &tokenResp); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif tokenResp.Response.SessionToken == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"empty session token received\")\n\t\t}\n\n\t\tcookieMap := make(map[string]string)\n\t\tfor _, cookie := range resp.Cookies() {\n\t\t\tcookieMap[cookie.Name] = cookie.Value\n\t\t}\n\n\t\tif len(cookieMap) > 0 {\n\n\t\t\tvar cookies []string\n\t\t\tfor name, value := range cookieMap {\n\t\t\t\tcookies = append(cookies, fmt.Sprintf(\"%s=%s\", name, value))\n\t\t\t}\n\t\t\td.Cookie = strings.Join(cookies, \"; \")\n\t\t\top.MustSaveDriverStorage(d)\n\n\t\t\t//fmt.Printf(\"getSessionToken :: Captured cookies: %s\\n\", d.Cookie)\n\t\t}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/util.go#L66-L102","documentation":"getSessionToken received HTTP 200 from /application/get_session_token.php, parsed the JSON successfully, but response.session_token was empty/absent. MediaFire returns 200 with an error payload (result: 'Error') when the supplied Cookie header is invalid, expired, or from a logged-out session — the scraper-style auth handshake depends entirely on that cookie.","triggerScenarios":"Calling Init or the token-renew cron with a stale Cookie; cookie captured from a browser session that has since logged out; MediaFire changing its response shape so the session_token key moves or is renamed.","commonSituations":"Tokens/cookies older than MediaFire's session lifetime; copying the cookie of a different account than the session token; Cloudflare interstitials returning HTML-ish JSON that unmarshals but contains no token.","solutions":["Re-open mediafire.com in the browser, confirm you are logged in, and re-extract both Cookie and session token","Check that the Cookie string is complete (all name=value pairs, no truncation)","If it persists, capture the raw response body (the commented-out Printf in the source) to see the API's error message and verify MediaFire's response format hasn't changed","Treat this error as a signal to re-do the full credential setup, not to retry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func plausibleCookie(c string) bool {\n    return strings.TrimSpace(c) != \"\" && strings.Contains(c, \"=\") && strings.Contains(c, \"xmf\")\n}","typeGuard":null,"tryCatchPattern":"Treat this as a fatal credential error: log it, mark the storage as needing re-configuration, and do not retry in a loop — an empty token means the cookie was rejected and only fresh cookie extraction fixes it.","preventionTips":["Re-extract cookie and session token together from one logged-in browser session","Log the raw response body on this failure to see MediaFire's error message","Alert on repeated token-acquisition failures rather than silently continuing"],"tags":["mediafire","authentication","session-token","cookies"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}