{"id":"86bbefaff1a0b57b","repo":"actix/actix-web","slug":"no-such-file","errorCode":null,"errorMessage":"No such file","messagePattern":"No such file","errorType":"exception","errorClass":"io::Error","httpStatus":404,"severity":"warning","filePath":"actix-files/src/service.rs","lineNumber":290,"sourceCode":"                        }\n                        Err(err) => return this.handle_err(err, req).await,\n                    }\n                }\n            }\n\n            if let Some((base, path)) = first_index_listing {\n                return Ok(this.show_index(req, base, path));\n            }\n\n            if found_unrenderable_dir {\n                return Ok(ServiceResponse::from_err(\n                    FilesError::IsDirectory,\n                    req.into_parts().0,\n                ));\n            }\n\n            let err = last_miss\n                .unwrap_or_else(|| io::Error::new(io::ErrorKind::NotFound, \"No such file\"));\n            this.handle_err(err, req).await\n        })\n    }\n}\n\n/// Flate doesn't have an accepted file extension, so it is not included here.\nconst SUPPORTED_PRECOMPRESSION_ENCODINGS: &[header::ContentEncoding] = &[\n    header::ContentEncoding::Brotli,\n    header::ContentEncoding::Gzip,\n    header::ContentEncoding::Zstd,\n    header::ContentEncoding::Identity,\n];\n\n/// Searches disk for an acceptable alternate encoding of the content at the given path, as\n/// preferred by the request's `Accept-Encoding` header. Returns the corresponding `NamedFile` with\n/// the most appropriate supported encoding, if any exist.\nasync fn find_compressed(\n    req: &ServiceRequest,","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/actix/actix-web/blob/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-files/src/service.rs#L272-L308","documentation":"io::Error with kind NotFound and message 'No such file' (service.rs:289-290) is the fallback error in FilesService::call when none of the configured root directories contained the requested path (last_miss stayed None). It is wrapped via handle_err into a response; because the kind is NotFound it renders as HTTP 404. If a default handler is configured it is invoked instead.","triggerScenarios":"A GET/HEAD request to a Files route whose path-on-disk does not exist in any registered directory, and no index file or default fallback matched. Also when the entire route resolves to nothing because the file was deleted.","commonSituations":"Missing static asset, wrong Files::new root, request for a file that was never deployed, or a typo in the URL. Also when redirect_to_slash / show_index are off and the directory itself has no index.","solutions":["Verify the file exists on disk under the directory passed to Files::new.","Register a default handler via Files::default_handler to serve a custom 404 or fallback route.","Enable .show_files_listing() or .index_file(\"index.html\") for directory requests if listing/index is desired.","Check for path-traversal filtering silently rejecting the request (hidden_files=false strips dotfiles)."],"exampleFix":"// before: bare Files, raw 404\nApp::new().service(Files::new(\"/static\", \"./assets\"))\n\n// after: graceful fallback\nApp::new().service(\n    Files::new(\"/static\", \"./assets\")\n        .index_file(\"index.html\")\n        .default_handler(web::to(|| async { HttpResponse::NotFound().body(\"not found\") })),\n)","handlingStrategy":"fallback","validationCode":"// Before relying on a file, optionally check existence (note: TOCTOU).\nuse std::path::Path;\nfn exists(p: &Path) -> bool { p.exists() }","typeGuard":null,"tryCatchPattern":"// Provide a default handler so 404s render your own page.\nApp::new().service(\n    Files::new(\"/static\", \"./assets\")\n        .default_handler(web::to(|| async {\n            HttpResponse::NotFound().body(\"not found\")\n        })),\n)","preventionTips":["Register a default_handler on Files for custom 404 behaviour.","Confirm the Files::new root directory and that assets are deployed there.","Enable index_file / show_files_listing if directory listings are intended."],"tags":["actix-files","http","not-found","static-files"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}