dotnet/machinelearning · error · ArgumentException
Null column string was specified as {columnPurpose} in colum
Error message
Null column string was specified as {columnPurpose} in column information What it means
Thrown by ValidateColumnInfoEnumerationProperty when one of the enumerable column-name properties of ColumnInformation (categorical, text, ignored, etc.) contains a null string element. The library forbids null entries because a null name cannot identify a column, and the message reports which purpose (columnPurpose) the offending list represents.
Source
Thrown at src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs:152
allColumns.Add(columnInformation.LabelColumnName);
if (columnInformation.ExampleWeightColumnName != null) { allColumns.Add(columnInformation.ExampleWeightColumnName); }
if (columnInformation.CategoricalColumnNames != null) { allColumns.AddRange(columnInformation.CategoricalColumnNames); }
if (columnInformation.NumericColumnNames != null) { allColumns.AddRange(columnInformation.NumericColumnNames); }
if (columnInformation.TextColumnNames != null) { allColumns.AddRange(columnInformation.TextColumnNames); }
if (columnInformation.IgnoredColumnNames != null) { allColumns.AddRange(columnInformation.IgnoredColumnNames); }
var duplicateColName = FindFirstDuplicate(allColumns);
if (duplicateColName != null)
{
throw new ArgumentException($"Duplicate column name {duplicateColName} is present in two or more distinct properties of provided column information", nameof(columnInformation));
}
}
private static void ValidateColumnInfoEnumerationProperty(IEnumerable<string> columns, string columnPurpose)
{
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");
}
View on GitHub (pinned to 7b76e69cf9)
Solutions
- Filter nulls from the enumeration before assigning: names.Where(n => n != null)
- Fix the source (config parsing, array allocation) that produced null entries
- Replace fixed-size array allocation with explicitly initialized non-null strings
Example fix
// before
var ignored = new string[3];
ignored[0] = "Id"; // [1] and [2] are null
var colInfo = new ColumnInformation { IgnoredColumnNames = ignored };
// after
var ignored = new[] { "Id" };
var colInfo = new ColumnInformation { IgnoredColumnNames = ignored }; Defensive patterns
Strategy: validation
Validate before calling
static string[] CleanNames(IEnumerable<string> names) => names?.Where(n => n != null).ToArray(); colInfo.IgnoredColumnNames = CleanNames(rawIgnored);
Type guard
static bool HasNoNulls(IEnumerable<string> names) => names == null || names.All(n => n != null);
Try / catch
try { var r = experiment.Execute(data, colInfo); }
catch (ArgumentException ex) when (ex.Message.Contains("Null column string")) { /* filter nulls from lists and retry */ } Prevention
- Use collection expressions or explicit initializers instead of new string[n]
- Apply Where(n => n != null) when building name lists from external config
- Enable nullable reference types so null string entries are flagged at compile time
When it happens
Trigger: Passing string[] or IEnumerable<string> containing null to ColumnInformation.CategoricalColumnNames / TextColumnNames / IgnoredColumnNames, e.g. from an array sized larger than the number of names filled in.
Common situations: new string[3] { "A", "B", null } patterns; building lists from possibly-null config values without filtering; LINQ Select over data with missing names yielding nulls.
Related errors
- Duplicate column name {duplicateColName} is present in two o
- If provided, {nameof(samplingKeyColumnName)} must be the sam
- Training data cannot be null
- Training data has 0 rows
- {DefaultColumnNames.Features} column must be of data type {N
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/44d15bb2c7dc089e.
Report an issue: GitHub.