{"record":{"id":"0215b2553bbb8887","repo":"AlistGo/alist","slug":"mediafire-file-search-failed-s","errorCode":null,"errorMessage":"MediaFire file search failed: %s","messagePattern":"MediaFire file search failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/mediafire/util.go","lineNumber":617,"sourceCode":"\n\treturn nil, fmt.Errorf(\"existing file not found\")\n}\n\nfunc (d *Mediafire) getFileByHash(_ context.Context, hash string) (*model.ObjThumb, error) {\n\tquery := map[string]string{\n\t\t\"session_token\":   d.SessionToken,\n\t\t\"response_format\": \"json\",\n\t\t\"hash\":            hash,\n\t}\n\n\tvar resp MediafireFileSearchResponse\n\t_, err := d.postForm(\"/file/get_info.php\", query, &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 file search failed: %s\", resp.Response.Result)\n\t}\n\n\tif len(resp.Response.FileInfo) == 0 {\n\t\treturn nil, fmt.Errorf(\"file not found by hash\")\n\t}\n\n\tfile := resp.Response.FileInfo[0]\n\treturn d.fileToObj(file), nil\n}\n","sourceCodeStart":599,"sourceCodeEnd":627,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/util.go#L599-L627","documentation":"The /file/get_info.php lookup by hash returned Result != Success when queried with a file hash. MediaFire refused the hash-based file info request — most commonly because no file with that hash exists in the account, which this endpoint reports as a non-Success result rather than an empty list.","triggerScenarios":"Searching for a hash that was never uploaded to this account; hash of a file uploaded to a different account; malformed hash string (wrong length/case for the expected hex format); session token invalid at query time.","commonSituations":"Instant-upload / dedup-by-hash checks where the file is genuinely new; verifying after a poll failure whether the file landed; copying hashes from another account or tool with a different hash scheme; stale sessions in long-running daemons.","solutions":["Check the embedded result string; hash-not-found results should map to a clean not-found error, not a generic failure","Validate the hash format (lowercase hex SHA-256, 64 chars) before calling","Re-login if the result indicates a session problem","If used for dedup, treat not-found as 'needs full upload'"],"exampleFix":"// before\nif resp.Response.Result != \"Success\" {\n    return nil, fmt.Errorf(\"MediaFire file search failed: %s\", resp.Response.Result)\n}\n\n// after\nif resp.Response.Result != \"Success\" {\n    if strings.Contains(strings.ToLower(resp.Response.Result), \"not found\") || strings.Contains(strings.ToLower(resp.Response.Result), \"invalid hash\") {\n        return nil, errs.ObjectNotFound\n    }\n    return nil, fmt.Errorf(\"MediaFire file search failed: %s\", resp.Response.Result)\n}","handlingStrategy":"validation","validationCode":"// Validate hash shape before the call\nif len(hash) != 64 { return errors.New(\"hash must be 64 hex chars\") }\nif _, err := hex.DecodeString(hash); err != nil { return fmt.Errorf(\"invalid hex hash: %w\", err) }","typeGuard":null,"tryCatchPattern":"// Map not-found results to a typed error\nobj, err := d.getFileByHash(ctx, hash)\nif err != nil {\n    if strings.Contains(strings.ToLower(err.Error()), \"not found\") {\n        return nil, errs.ObjectNotFound\n    }\n    return nil, err\n}","preventionTips":["Normalize hash to lowercase hex before querying","Treat not-found as expected in dedup flows, not as a bug","Re-login when results look session-related"],"tags":["mediafire","hash-lookup","api-error","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}