{"record":{"id":"86bbefaff1a0b57b","repo":"actix/actix-web","slug":"no-such-file","errorCode":null,"errorMessage":"No such file","messagePattern":"No such file","errorType":"http","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/7ae209e4a4f3c8df61cacb9c2d3b8ef28ebda0d6/actix-files/src/service.rs#L272-L308","documentation":"An io::Error of kind NotFound with message \"No such file\" is the fallback used by the Files service (service.rs:290) when directory traversal completes without ever recording a NotFound/NotADirectory miss. It is passed to handle_err, which by default produces a 404 response. In practice most 404s come from the stored last_miss IO error; this string is the edge-case default when no open was even attempted.","triggerScenarios":"A request maps to a directory that exists but contains no index file, directory listing is disabled, and no candidate file open produced a NotFound error - e.g. an empty resolved path or a config where index/show_index are both off and the target is an unrenderable directory branch.","commonSituations":"Misconfigured Files::new root pointing at a missing directory; index file not set and listing disabled; deploy where static assets were not copied into the served directory.","solutions":["Verify the directory configured in Files::new(...) exists and is readable by the server process.","Set an index file via .index_file(\"index.html\") and/or enable .show_files(true) for listing.","Register a custom default handler (App::default_service) to render a friendly 404 page."],"exampleFix":"// before\nApp::new().service(Files::new(\"/assets\", \"/nonexistent/dir\"))\n\n// after\nApp::new().service(\n    Files::new(\"/assets\", \"/srv/site/assets\")\n        .index_file(\"index.html\")\n)","handlingStrategy":"fallback","validationCode":"// Confirm the served directory exists at startup\nlet root = Path::new(SERVE_DIR);\nassert!(root.is_dir(), \"static dir missing: {SERVE_DIR}\");","typeGuard":null,"tryCatchPattern":"// Provide a friendly 404 fallback\nApp::new()\n    .service(Files::new(\"/assets\", SERVE_DIR).index_file(\"index.html\"))\n    .default_service(web::to(|| HttpResponse::NotFound().body(\"not found\")))","preventionTips":["Verify the served directory exists and is readable at startup.","Set an index file or enable show_files as appropriate.","Deploy static assets as part of your build/pipeline."],"tags":["filesystem","actix-files","http-404","configuration"],"backgroundTag":null,"analyzedSha":"7ae209e4a4f3c8df61cacb9c2d3b8ef28ebda0d6","analyzedAt":"2026-08-09T01:01:40.926Z","contentChangedAt":"2026-08-09T01:01:40.926Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}