{"record":{"id":"630c588fe9d6cf9e","repo":"AlistGo/alist","slug":"file-not-found-by-hash","errorCode":null,"errorMessage":"file not found by hash","messagePattern":"file not found by hash","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"drivers/mediafire/util.go","lineNumber":621,"sourceCode":"func (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":603,"sourceCodeEnd":627,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/util.go#L603-L627","documentation":"The hash lookup succeeded (Result=Success) but the FileInfo array came back empty — MediaFire accepted the query and reports zero files matching the hash. It is the empty-result counterpart to the file-search failure and means the file is definitively not in this account.","triggerScenarios":"Any getFileByHash call where no file with that SHA-1/fingerprint hash exists in the account; hash of a file still mid-upload so not yet indexed; querying immediately after upload before indexing completes.","commonSituations":"Dedup checks before upload (expected empty); post-upload verification racing MediaFire's indexing; verifying whether a poll-failed upload actually landed (it did not).","solutions":["Map this to a standard not-found error and handle it as the normal 'file absent' case","If the file was just uploaded, wait briefly and retry once — indexing is asynchronous","Verify the hash matches the algorithm MediaFire uses for file fingerprints before relying on it","Use folder listing by name as a fallback verification path"],"exampleFix":"// before\nif len(resp.Response.FileInfo) == 0 {\n    return nil, fmt.Errorf(\"file not found by hash\")\n}\n\n// after\nif len(resp.Response.FileInfo) == 0 {\n    return nil, errs.ObjectNotFound // standard, typed not-found for callers\n}","handlingStrategy":"validation","validationCode":"if hash == \"\" { return errors.New(\"empty hash\") }\n// post-upload: brief retry window for indexing\nif justUploaded { time.Sleep(2 * time.Second) }","typeGuard":null,"tryCatchPattern":"// Empty-result is a clean not-found\nfile, err := d.getFileByHash(ctx, hash)\nif err != nil && strings.Contains(err.Error(), \"file not found by hash\") {\n    return nil, errs.ObjectNotFound\n}","preventionTips":["Retry once after a short delay for freshly uploaded files","Use errs.ObjectNotFound so callers branch cleanly","Fall back to name-based lookup when hash lookup misses"],"tags":["mediafire","hash-lookup","not-found","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}