{"record":{"id":"6aba1f3fd0ac2584","repo":"AlistGo/alist","slug":"init-mediafire-critical-missing-sessiontoke","errorCode":null,"errorMessage":"Init :: [MediaFire] {critical} missing sessionToken","messagePattern":"Init :: \\[MediaFire\\] (.+?) missing sessionToken","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"drivers/mediafire/driver.go","lineNumber":54,"sourceCode":"\thostBase   string\n\tmaxRetries int\n\n\tsecChUa         string\n\tsecChUaPlatform string\n\tuserAgent       string\n}\n\nfunc (d *Mediafire) Config() driver.Config {\n\treturn config\n}\n\nfunc (d *Mediafire) GetAddition() driver.Additional {\n\treturn &d.Addition\n}\n\nfunc (d *Mediafire) Init(ctx context.Context) error {\n\tif d.SessionToken == \"\" {\n\t\treturn fmt.Errorf(\"Init :: [MediaFire] {critical} missing sessionToken\")\n\t}\n\n\tif d.Cookie == \"\" {\n\t\treturn fmt.Errorf(\"Init :: [MediaFire] {critical} missing Cookie\")\n\t}\n\n\tif _, err := d.getSessionToken(ctx); err != nil {\n\n\t\td.renewToken(ctx)\n\n\t\tnum := rand.Intn(4) + 6\n\n\t\td.cron = cron.NewCron(time.Minute * time.Duration(num))\n\t\td.cron.Do(func() {\n\t\t\td.renewToken(ctx)\n\t\t})\n\n\t}","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/driver.go#L36-L72","documentation":"Mediafire driver Init aborts because the Addition struct has an empty SessionToken. The driver is a scraping-style client that authenticates with a pre-obtained session token plus browser Cookie; without it, no API call can be signed. Init returns this error, which the driver framework surfaces as storage initialization failure.","triggerScenarios":"Adding a MediaFire storage in the admin UI without pasting a session token; restoring a storage config from JSON where the session_token field was dropped; the token never having been persisted (MustSaveDriverStorage not yet run on first setup).","commonSituations":"First-time setup where the user filled Cookie but skipped extracting the session_token from the browser; migrating configs between instances; secret fields stripped during config export.","solutions":["Open mediafire.com logged in, extract session_token (and cookie) from browser devtools and fill both fields in the storage config","Verify the saved storage JSON actually contains the token (it is persisted via op.MustSaveDriverStorage)","Re-save the storage config after pasting so Init runs again with the populated Addition"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func (d *Mediafire) Init(ctx context.Context) error {\n    if strings.TrimSpace(d.SessionToken) == \"\" {\n        return fmt.Errorf(\"sessionToken is required: extract it from a logged-in mediafire.com browser session\")\n    }\n    ...\n}","typeGuard":null,"tryCatchPattern":"The framework already surfaces Init errors in the storage status UI — catch nothing; instead present actionable text in the error so the admin knows which field to fill.","preventionTips":["Validate both SessionToken and Cookie fields in the admin form before saving","Document the browser-devtools extraction steps in the storage's help text","Persist credentials via driver storage immediately after first successful Init"],"tags":["mediafire","configuration","authentication","driver-init"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}