{"record":{"id":"6f4e51339135831b","repo":"Flow-Launcher/Flow.Launcher","slug":"invalid-file-path","errorCode":null,"errorMessage":"Invalid file path","messagePattern":"Invalid file path","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Flow.Launcher.Infrastructure/Storage/JsonStorage.cs","lineNumber":43,"sourceCode":"        public const string FileSuffix = \".json\";\n\n        protected string FilePath { get; init; } = null!;\n\n        private string TempFilePath => $\"{FilePath}.tmp\";\n\n        private string BackupFilePath => $\"{FilePath}.bak\";\n\n        protected string DirectoryPath { get; init; } = null!;\n\n        // Let the derived class to set the file path\n        protected JsonStorage()\n        {\n        }\n\n        public JsonStorage(string filePath)\n        {\n            FilePath = filePath;\n            DirectoryPath = Path.GetDirectoryName(filePath) ?? throw new ArgumentException(\"Invalid file path\");\n\n            FilesFolders.ValidateDirectory(DirectoryPath);\n        }\n\n        public bool Exists()\n        {\n            return File.Exists(FilePath);\n        }\n\n        public void Delete()\n        {\n            foreach (var path in new[] { FilePath, BackupFilePath, TempFilePath })\n            {\n                if (File.Exists(path))\n                {\n                    File.Delete(path);\n                }\n            }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/Flow-Launcher/Flow.Launcher/blob/7fc63b07bbaa10a0f0b2601487913fcba9ed24b0/Flow.Launcher.Infrastructure/Storage/JsonStorage.cs#L25-L61","documentation":"Thrown as ArgumentException from the JsonStorage constructor when Path.GetDirectoryName(filePath) returns null. That happens when filePath is a root (e.g. 'C:\\'), a UNC root, or an invalid path string with no directory component. The constructor then immediately calls FilesFolders.ValidateDirectory(DirectoryPath), so this guard ensures DirectoryPath is never null before validation.","triggerScenarios":"A storage subclass or caller constructs JsonStorage with a path that has no directory portion: a bare filename resolved against the current drive root, a path like '\\', 'C:', or an empty/malformed string that Path.GetDirectoryName treats as rootless. Most commonly a misconfigured BaseDirectory or a plugin passing a relative path that resolved unexpectedly.","commonSituations":"A plugin's settings path computed from a config value that is empty or root-only; a path constructed by combining an empty base directory with a filename that itself contains no directory; passing an already-rooted drive letter without a subfolder; misconfigured portable-mode DataDirectory.","solutions":["Inspect the filePath passed to the JsonStorage constructor — it should be a full path like 'C:\\Users\\...\\plugin\\settings.json'.","Ensure the base directory (BaseDirectory / DataDirectory) is non-empty before combining with the filename.","Use Path.Combine with an explicit, validated directory rather than building the path manually.","Log the filePath at construction time in your subclass to catch bad inputs during development."],"exampleFix":"// before\npublic JsonStorage(string filePath)\n{\n    FilePath = filePath;\n    DirectoryPath = Path.GetDirectoryName(filePath) ?? throw new ArgumentException(\"Invalid file path\");\n}\n\n// after — validate and report the offending path\nDirectoryPath = Path.GetDirectoryName(filePath);\nif (string.IsNullOrEmpty(DirectoryPath))\n    throw new ArgumentException($\"Invalid file path (no directory component): '{filePath}'\", nameof(filePath));","handlingStrategy":"validation","validationCode":"var dir = Path.GetDirectoryName(filePath);\nif (string.IsNullOrEmpty(dir))\n    throw new ArgumentException($\"Storage path has no directory: '{filePath}'\", nameof(filePath));\nFilesFolders.ValidateDirectory(dir);","typeGuard":"static bool IsValidStoragePath(string p) =>\n    !string.IsNullOrWhiteSpace(p) && !string.IsNullOrEmpty(Path.GetDirectoryName(p))\n    && Path.GetInvalidPathChars().All(c => !p.Contains(c));","tryCatchPattern":"null","preventionTips":["Always build storage paths with Path.Combine(validatedBaseDirectory, fileName).","Assert the base directory is non-empty before constructing the path.","Log the filePath at construction in subclasses to catch bad inputs early.","Unit-test storage construction with edge-case paths."],"tags":["storage","json","filesystem","path","config"],"backgroundTag":null,"analyzedSha":"7fc63b07bbaa10a0f0b2601487913fcba9ed24b0","analyzedAt":"2026-08-13T14:54:20.914Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}