dotnet/machinelearning · critical · ArgumentNullException
Provided path cannot be null
Error message
Provided path cannot be null
What it means
Thrown by UserInputValidationUtil.ValidatePath when the file path supplied to the infer-columns API (ValidateInferColumnsArgs) is null. The path identifies the training data file to inspect, so it is mandatory and reported via ArgumentNullException naming the path parameter.
Source
Thrown at src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs:168
if (columns?.Contains(null) == true)
{
throw new ArgumentException($"Null column string was specified as {columnPurpose} in column information");
}
}
private static void ValidateLabelColumn(string labelColumn)
{
if (labelColumn == null)
{
throw new ArgumentException("Provided label column cannot be null");
}
}
private static void ValidatePath(string path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path), "Provided path cannot be null");
}
var fileInfo = new FileInfo(path);
if (!fileInfo.Exists)
{
throw new ArgumentException($"File '{path}' does not exist", nameof(path));
}
if (fileInfo.Length == 0)
{
throw new ArgumentException($"File at path '{path}' cannot be empty", nameof(path));
}
}
private static void ValidateValidationData(IDataView trainData, IDataView validationData)
{
if (validationData == null)View on GitHub (pinned to 7b76e69cf9)
Solutions
- Provide a valid file path string to the InferColumns call
- Resolve the path from configuration with a null/empty check before calling
- Fix the config/CLI plumbing so the path value is populated
Example fix
// before
string dataPath = configuration["DataPath"]; // null
var columns = mlContext.Auto().InferColumns<ModelInput>(dataPath, labelColumnName: "Label");
// after
string dataPath = configuration["DataPath"] ?? throw new InvalidOperationException("DataPath config missing");
var columns = mlContext.Auto().InferColumns<ModelInput>(dataPath, labelColumnName: "Label"); Defensive patterns
Strategy: type-guard
Validate before calling
if (string.IsNullOrWhiteSpace(path)) throw new InvalidOperationException("Data file path is required"); Type guard
static bool HasPath(string p) => !string.IsNullOrWhiteSpace(p);
Try / catch
try { var cols = mlContext.Auto().InferColumns(path, labelColumnName); }
catch (ArgumentNullException ex) when (ex.ParamName == "path") { /* resolve path from fallback config and retry */ } Prevention
- Fail fast at startup if the configured data path is null/empty
- Wrap path resolution in one helper that guarantees non-null output
- Validate required CLI/config arguments before running experiments
When it happens
Trigger: Calling InferColumns overloads with path = null, usually because a config value or command-line argument was not supplied.
Common situations: Missing appsetting/connection-string entry for the data file path; CLI args array missing an element; environment-specific path variable empty in CI.
Related errors
- Training data cannot be null
- Provided label column cannot be null
- File '{path}' does not exist
- If provided, {nameof(samplingKeyColumnName)} must be the sam
- Training data has 0 rows
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/e40c02ee57c2bddb.
Report an issue: GitHub.