{"record":{"id":"f6e4d282d0221deb","repo":"AlistGo/alist","slug":"mediafire-api-error-s","errorCode":null,"errorMessage":"MediaFire API error: %s","messagePattern":"MediaFire API error: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/mediafire/driver.go","lineNumber":138,"sourceCode":"\t}, nil\n}\n\nfunc (d *Mediafire) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {\n\tdata := map[string]string{\n\t\t\"session_token\":   d.SessionToken,\n\t\t\"response_format\": \"json\",\n\t\t\"parent_key\":      parentDir.GetID(),\n\t\t\"foldername\":      dirName,\n\t}\n\n\tvar resp MediafireFolderCreateResponse\n\t_, err := d.postForm(\"/folder/create.php\", data, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.Response.Result != \"Success\" {\n\t\treturn nil, fmt.Errorf(\"MediaFire API error: %s\", resp.Response.Result)\n\t}\n\n\tcreated, _ := time.Parse(\"2006-01-02T15:04:05Z\", resp.Response.CreatedUTC)\n\n\treturn &model.ObjThumb{\n\t\tObject: model.Object{\n\t\t\tID:       resp.Response.FolderKey,\n\t\t\tName:     resp.Response.Name,\n\t\t\tSize:     0,\n\t\t\tModified: created,\n\t\t\tCtime:    created,\n\t\t\tIsFolder: true,\n\t\t},\n\t\tThumbnail: model.Thumbnail{},\n\t}, nil\n}\n\nfunc (d *Mediafire) Move(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/driver.go#L120-L156","documentation":"MakeDir posted to MediaFire's /folder/create.php and got an HTTP 200 JSON response whose response.result field is not 'Success' — e.g. 'Error' with a message. The %s prints only the result code, so the API's human-readable message field (usually also present in the payload) is lost. Typical causes: invalid/expired parent folder key, duplicate folder name, or session token revoked.","triggerScenarios":"Creating a folder under a parent whose folder_key was deleted; creating a folder when the session token expired mid-session; MediaFire rate-limiting the scraping-style API.","commonSituations":"Long-running instances whose cron-based token renewal (every 6-9 minutes) failed silently, then a mkdir request arrives; concurrent uploads racing to create the same directory.","solutions":["Retry once after forcing a token refresh (call getSessionToken) — expired tokens are the most frequent cause","Verify the parent folder key still exists by listing it in the MediaFire web UI","If a duplicate name, list the destination first and reuse the existing folder","Improve the error to include resp.Response.Message so the real API reason is visible"],"exampleFix":"// before: only the result code is reported\nif resp.Response.Result != \"Success\" {\n    return nil, fmt.Errorf(\"MediaFire API error: %s\", resp.Response.Result)\n}\n\n// after: include the API's message field for a diagnosable error\nif resp.Response.Result != \"Success\" {\n    return nil, fmt.Errorf(\"MediaFire API error: %s: %s\", resp.Response.Result, resp.Response.Message)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"On 'MediaFire API error' from folder/create: refresh the session token once (getSessionToken), retry MakeDir; if it still fails, surface the API message. Also pre-check for an existing folder with the same name via List to avoid duplicate-name results.","preventionTips":["Wrap all MediaFire mutating calls in a retry-once-after-token-refresh helper","Include response.message in error strings for diagnosability","Idempotency-check directory creation by listing the parent first"],"tags":["mediafire","api-error","mkdir","authentication"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}