{"record":{"id":"6417166b1dbabfb7","repo":"dotnet/machinelearning","slug":"file-at-path-path-cannot-be-empty","errorCode":null,"errorMessage":"File at path '{path}' cannot be empty","messagePattern":"File at path '(.+?)' cannot be empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":180,"sourceCode":"        }\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));\n            }\n\n            const string schemaMismatchError = \"Training data and validation data schemas do not match.\";\n\n            if (trainData.Schema.Count(c => !c.IsHidden) != validationData.Schema.Count(c => !c.IsHidden))","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L162-L198","documentation":"ML.NET AutoML validates user-supplied file paths before running an experiment. This ArgumentException is thrown by ValidatePath when the file at the given path exists but has a length of 0 bytes. AutoML refuses empty files because training/inference on an empty dataset is meaningless.","triggerScenarios":"Calling any AutoML API that resolves to ValidateInferColumnsArgs (e.g. InferColumns or Experiment API) with a path to a file that exists but contains 0 bytes — e.g. the file was truncated by a failed download, created by a crashed pipeline, or touched by a script before content was written.","commonSituations":"Downloaded CSV interrupted mid-write; output redirection creating an empty file; upstream ETL job produced an empty extract; pointing at a file created by `touch` or a logger that never flushed.","solutions":["Verify the file has content: check `new FileInfo(path).Length > 0` before calling the API.","Fix the upstream producer so the file is fully written (atomic write, then rename).","Re-download or regenerate the dataset.","Point to the correct file — you may be looking at a placeholder with the same name."],"exampleFix":"// before\nawait client.DownloadFileTaskAsync(url, \"data.csv\"); // may leave empty file on failure\n// after\nawait client.DownloadFileTaskAsync(url, \"data.tmp\");\nif (new FileInfo(\"data.tmp\").Length == 0) throw new IOException(\"download produced empty file\");\nFile.Move(\"data.tmp\", \"data.csv\");","handlingStrategy":"validation","validationCode":"var fi = new FileInfo(path);\nif (!fi.Exists) throw new FileNotFoundException(path);\nif (fi.Length == 0) throw new ArgumentException($\"File '{path}' is empty\");","typeGuard":null,"tryCatchPattern":"try { automlResult = experiment.Execute(trainDataPath, ...); }\ncatch (ArgumentException ex) when (ex.ParamName == \"path\") { /* surface empty-file guidance */ }","preventionTips":["Check file length > 0 before invoking AutoML APIs","Use atomic write-then-rename in data producers","Validate downloads by size/checksum before use"],"tags":["validation","file","automl"],"backgroundTag":"empty-required-field","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}