{"record":{"id":"e4a0edf61c23081d","repo":"dotnet/machinelearning","slug":"provided-columnpurpose-column-columnname-was-e4a0ed","errorCode":null,"errorMessage":"Provided {columnPurpose} column '{columnName}' was of type {itemType}, but only types {string.Join(\", \", allowedTypes)} are allowed.","messagePattern":"Provided (.+?) column '(.+?)' was of type (.+?), but only types (.+?) are allowed\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":278,"sourceCode":"                throw new ArgumentException(exceptionMessage);\n            }\n\n            if (allowedTypes == null)\n            {\n                return;\n            }\n            var column = nullableColumn.Value;\n            var itemType = column.Type.GetItemType();\n            if (!allowedTypes.Contains(itemType))\n            {\n                if (allowedTypes.Count() == 1)\n                {\n                    throw new ArgumentException($\"Provided {columnPurpose} column '{columnName}' was of type {itemType}, \" +\n                        $\"but only type {allowedTypes.First()} is allowed.\");\n                }\n                else\n                {\n                    throw new ArgumentException($\"Provided {columnPurpose} column '{columnName}' was of type {itemType}, \" +\n                        $\"but only types {string.Join(\", \", allowedTypes)} are allowed.\");\n                }\n            }\n        }\n\n        private static string ClosestNamed(IDataView trainData, string columnName, int maxAllowableEditDistance = int.MaxValue)\n        {\n            var minEditDistance = int.MaxValue;\n            var closestNamed = string.Empty;\n            foreach (var column in trainData.Schema)\n            {\n                var editDistance = StringEditDistance.GetLevenshteinDistance(column.Name, columnName);\n                if (editDistance < minEditDistance)\n                {\n                    minEditDistance = editDistance;\n                    closestNamed = column.Name;\n                }\n            }","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L260-L296","documentation":"The multi-type branch of ValidateTrainDataColumn's type check: when the column's item type is not among the several allowedTypes, this ArgumentException lists the actual type and all allowed types. Same root cause as the single-type variant, just with a richer allowed set.","triggerScenarios":"Designating a label column whose item type isn't in the task's allowed set (e.g. classification allows Single and NumberDataViewType key types — a Double or DateTime label fails).","commonSituations":"DateTime or Double labels for a task expecting Single/keys; label loaded as string for multiclass that requires KeyType; wrong column designated as label.","solutions":["Convert the column to one of the listed allowed types (ConvertType transform) before Execute.","Correct the ColumnInformation entry to a column whose type matches the allowed list.","Use AutoML's InferColumns/InferColumnInformation so column purposes and types are inferred consistently."],"exampleFix":"// before\nvar colInfo = new ColumnInformation { LabelColumnName = \"Date\" }; // DateTime, task allows Single\n// after\nvar typed = mlContext.Transforms.Conversion.ConvertType(\"Date\", outputKind: DataKind.Single).Fit(trainData).Transform(trainData);","handlingStrategy":"validation","validationCode":"var itemType = trainData.Schema[labelCol].Type.GetItemType();\nvar allowed = new[] { NumberDataViewType.Single, /* task-specific types */ };\nif (!allowed.Contains(itemType)) throw new InvalidOperationException($\"{itemType} not allowed for label\");","typeGuard":null,"tryCatchPattern":"try { result = experiment.Execute(trainData, settings, columnInfo); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"only types\")) { /* convert to one of the listed types */ }","preventionTips":["Consult the task's allowed label types (GetAllowedLabelTypes logic) up front","Use ConvertType to normalize label columns","Prefer inferred ColumnInformation over manual entry"],"tags":["type-mismatch","column","validation"],"backgroundTag":"type-mismatch","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"}