{"record":{"id":"44d15bb2c7dc089e","repo":"dotnet/machinelearning","slug":"null-column-string-was-specified-as-columnpurpose","errorCode":null,"errorMessage":"Null column string was specified as {columnPurpose} in column information","messagePattern":"Null column string was specified as (.+?) in column information","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":152,"sourceCode":"            allColumns.Add(columnInformation.LabelColumnName);\n            if (columnInformation.ExampleWeightColumnName != null) { allColumns.Add(columnInformation.ExampleWeightColumnName); }\n            if (columnInformation.CategoricalColumnNames != null) { allColumns.AddRange(columnInformation.CategoricalColumnNames); }\n            if (columnInformation.NumericColumnNames != null) { allColumns.AddRange(columnInformation.NumericColumnNames); }\n            if (columnInformation.TextColumnNames != null) { allColumns.AddRange(columnInformation.TextColumnNames); }\n            if (columnInformation.IgnoredColumnNames != null) { allColumns.AddRange(columnInformation.IgnoredColumnNames); }\n\n            var duplicateColName = FindFirstDuplicate(allColumns);\n            if (duplicateColName != null)\n            {\n                throw new ArgumentException($\"Duplicate column name {duplicateColName} is present in two or more distinct properties of provided column information\", nameof(columnInformation));\n            }\n        }\n\n        private static void ValidateColumnInfoEnumerationProperty(IEnumerable<string> columns, string columnPurpose)\n        {\n            if (columns?.Contains(null) == true)\n            {\n                throw new ArgumentException($\"Null column string was specified as {columnPurpose} in column information\");\n            }\n        }\n\n        private static void ValidateLabelColumn(string labelColumn)\n        {\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","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L134-L170","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar ignored = new string[3];\nignored[0] = \"Id\"; // [1] and [2] are null\nvar colInfo = new ColumnInformation { IgnoredColumnNames = ignored };\n\n// after\nvar ignored = new[] { \"Id\" };\nvar colInfo = new ColumnInformation { IgnoredColumnNames = ignored };","handlingStrategy":"validation","validationCode":"static string[] CleanNames(IEnumerable<string> names) => names?.Where(n => n != null).ToArray();\ncolInfo.IgnoredColumnNames = CleanNames(rawIgnored);","typeGuard":"static bool HasNoNulls(IEnumerable<string> names) => names == null || names.All(n => n != null);","tryCatchPattern":"try { var r = experiment.Execute(data, colInfo); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Null column string\")) { /* filter nulls from lists and retry */ }","preventionTips":["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"],"tags":["dotnet","mlnet","automl","null-value","column-information"],"backgroundTag":"null-argument","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"}