{"record":{"id":"f416201c80e12567","repo":"cefsharp/CefSharp","slug":"please-provide-a-valid-filepath","errorCode":null,"errorMessage":"Please provide a valid filePath","messagePattern":"Please provide a valid filePath","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"CefSharp/Internals/FileResourceHandler.cs","lineNumber":44,"sourceCode":"        /// Gets or sets the Mime Type.\n        /// </summary>\n        public string MimeType { get; set; }\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"FileResourceHandler\"/> class.\n        /// </summary>\n        /// <param name=\"mimeType\">mimeType</param>\n        /// <param name=\"filePath\">filePath</param>\n        public FileResourceHandler(string mimeType, string filePath)\n        {\n            if (string.IsNullOrEmpty(mimeType))\n            {\n                throw new ArgumentNullException(\"mimeType\", \"Please provide a valid mimeType\");\n            }\n\n            if (string.IsNullOrEmpty(filePath))\n            {\n                throw new ArgumentNullException(\"filePath\", \"Please provide a valid filePath\");\n            }\n\n            if (!File.Exists(filePath))\n            {\n                throw new FileNotFoundException(\"Unable to create FileResourceHandler\", filePath);\n            }\n\n            MimeType = mimeType;\n            FilePath = filePath;\n        }\n\n        bool IResourceHandler.ProcessRequest(IRequest request, ICallback callback)\n        {\n            //Should never be called\n            throw new NotImplementedException(\"This method should never be called\");\n        }\n\n        void IResourceHandler.GetResponseHeaders(IResponse response, out long responseLength, out string redirectUrl)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp/Internals/FileResourceHandler.cs#L26-L62","documentation":"Thrown by the FileResourceHandler constructor when filePath is null or empty. The handler's sole purpose is to stream a file, so an absent path leaves nothing to serve; the constructor rejects it with ArgumentNullException before CEF ever tries to open it.","triggerScenarios":"Constructing new FileResourceHandler(\"text/html\", null) or new FileResourceHandler(\"text/html\", \"\") where the path variable was never assigned, was cleared, or came from a failed lookup.","commonSituations":"Serving an asset whose path was resolved from a config/lookup that returned null/empty; passing a user-supplied download target that was unset; placeholder field not yet populated before handler construction.","solutions":["Ensure filePath is a non-empty, fully qualified path before constructing the handler.","Return null from GetResourceHandler when no file path is available instead of forcing construction.","Resolve/validate the path upstream (e.g. Server.MapPath, AppDomain.BaseDirectory combine) and check it."],"exampleFix":"// before\nreturn new FileResourceHandler(\"text/html\", resolvedPath);\n\n// after\nif (string.IsNullOrEmpty(resolvedPath)) return null;\nreturn new FileResourceHandler(\"text/html\", resolvedPath);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(filePath))\n{\n    return null; // let default handling proceed\n}\nreturn new FileResourceHandler(mimeType, filePath);","typeGuard":"static bool HasFilePath(string path) => !string.IsNullOrEmpty(path);","tryCatchPattern":null,"preventionTips":["Resolve and validate filePath (absolute) before constructing the handler.","Return null from GetResourceHandler when no path is available.","Do not construct the handler with unresolved/placeholder paths."],"tags":["resource-handler","validation","null-reference","constructor","cefsharp"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}