{"record":{"id":"10ce7fc75ced58d3","repo":"dotnet/machinelearning","slug":"file-path-does-not-exist","errorCode":null,"errorMessage":"File '{path}' does not exist","messagePattern":"File '(.+?)' does not exist","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":175,"sourceCode":"        {\n            if (labelColumn == null)\n            {\n                throw new ArgumentException(\"Provided label column cannot be null\");\n            }\n        }\n\n        private static void ValidatePath(string path)\n        {\n            if (path == null)\n            {\n                throw new ArgumentNullException(nameof(path), \"Provided path cannot be null\");\n            }\n\n            var fileInfo = new FileInfo(path);\n\n            if (!fileInfo.Exists)\n            {\n                throw new ArgumentException($\"File '{path}' does not exist\", nameof(path));\n            }\n\n            if (fileInfo.Length == 0)\n            {\n                throw new ArgumentException($\"File at path '{path}' cannot be empty\", nameof(path));\n            }\n        }\n\n        private static void ValidateValidationData(IDataView trainData, IDataView validationData)\n        {\n            if (validationData == null)\n            {\n                return;\n            }\n\n            if (DatasetDimensionsUtil.IsDataViewEmpty(validationData))\n            {\n                throw new ArgumentException(\"Validation data has 0 rows\", nameof(validationData));","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L157-L193","documentation":"Thrown by UserInputValidationUtil.ValidatePath when the supplied file path is non-null but no file exists at that location on disk. ValidatePath constructs a FileInfo and requires Exists; the message includes the offending path so the developer can correct it.","triggerScenarios":"Calling AutoML InferColumns with a path to a missing file: typo in filename, wrong working directory with a relative path, file deleted/moved between runs.","commonSituations":"Relative paths that resolve differently when running from bin/Debug vs project root; case-sensitive file systems in Linux containers; deployment package not copying the data file; Windows/Linux path separator mistakes.","solutions":["Verify the file exists with File.Exists(path) before calling and correct the path","Use absolute paths built with Path.Combine(AppContext.BaseDirectory, ...) instead of bare relative names","Ensure the data file is included in build/deployment output (Copy to Output Directory)"],"exampleFix":"// before\nvar columns = mlContext.Auto().InferColumns(\"train.csv\", labelColumnName: \"Label\"); // not found when run from bin dir\n\n// after\nstring dataPath = Path.Combine(AppContext.BaseDirectory, \"train.csv\");\nif (!File.Exists(dataPath)) throw new FileNotFoundException(\"Training data missing\", dataPath);\nvar columns = mlContext.Auto().InferColumns(dataPath, labelColumnName: \"Label\");","handlingStrategy":"validation","validationCode":"if (!File.Exists(path)) throw new FileNotFoundException($\"Data file not found: {path}\", path);","typeGuard":null,"tryCatchPattern":"try { var cols = mlContext.Auto().InferColumns(path, labelColumnName); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"does not exist\")) { /* log resolved absolute path and correct config */ }","preventionTips":["Always call File.Exists on the absolute path before use","Build paths with Path.Combine(AppContext.BaseDirectory, ...) rather than raw relative paths","Set data files to Copy to Output Directory and verify them in CI on all target OSes"],"tags":["dotnet","mlnet","automl","file-not-found","path"],"backgroundTag":"file-not-found","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}