{"record":{"id":"5f53e3e97a0ccba1","repo":"dotnet/machinelearning","slug":"unsupported-task-type-task","errorCode":null,"errorMessage":"Unsupported task type: {task}","messagePattern":"Unsupported task type: (.+?)","errorType":"validation","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs","lineNumber":323,"sourceCode":"        }\n\n        private static IEnumerable<DataViewType> GetAllowedLabelTypes(TaskKind task)\n        {\n            switch (task)\n            {\n                case TaskKind.BinaryClassification:\n                    return new DataViewType[] { BooleanDataViewType.Instance };\n                // Multiclass label types are flexible, as we convert the label to a key type\n                // (if input label is not already a key) before invoking the trainer.\n                case TaskKind.MulticlassClassification:\n                    return null;\n                case TaskKind.Regression:\n                case TaskKind.Recommendation:\n                    return new DataViewType[] { NumberDataViewType.Single };\n                case TaskKind.Ranking:\n                    return new DataViewType[] { NumberDataViewType.Single };\n                default:\n                    throw new NotSupportedException($\"Unsupported task type: {task}\");\n            }\n        }\n    }\n}\n","sourceCodeStart":305,"sourceCodeEnd":328,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs#L305-L328","documentation":"GetAllowedLabelTypes maps an AutoML TaskKind to the label DataViewTypes that task supports. If the task falls through the switch, NotSupportedException 'Unsupported task type' is thrown — meaning the task value isn't one of binary/multiclass/regression/recommendation/ranking.","triggerScenarios":"Passing a TaskName/Task to AutoML APIs whose mapped TaskKind isn't handled (future/unknown enum value, default case), typically via ValidateColumnInformation during Execute on a newer enum value used with an older ML.NET build.","commonSituations":"Assembly/version mismatch where a new task enum was serialized or specified but the loaded Microsoft.ML.AutoML doesn't recognize it; typo casting an int to TaskKind; configuration-driven task names mapped incorrectly.","solutions":["Use a supported task: binary/multiclass classification, regression, recommendation, or ranking.","Update the Microsoft.ML.AutoML package to a version matching the task enum value you specify.","Log the actual task value to confirm what is being passed; fix the config/code mapping."],"exampleFix":"// before\nvar settings = new MulticlassExperimentSettings(...); // task resolved to unknown kind on older package\n// after\ndotnet add package Microsoft.ML.AutoML --version <latest>\nvar experiment = mlContext.Auto().CreateMulticlassExperiment(settings);","handlingStrategy":"type-guard","validationCode":"var supported = new[] { \"binary-classification\", \"multiclass-classification\", \"regression\", \"recommendation\", \"ranking\" };\nif (!supported.Contains(taskName)) throw new InvalidOperationException($\"task {taskName} not supported by this ML.NET version\");","typeGuard":"bool IsKnownTaskKind(TaskKind kind) =>\n    kind is TaskKind.BinaryClassification or TaskKind.MulticlassClassification or TaskKind.Regression or TaskKind.Recommendation or TaskKind.Ranking;","tryCatchPattern":"try { result = experiment.Execute(trainData, settings); }\ncatch (NotSupportedException ex) when (ex.Message.StartsWith(\"Unsupported task type\")) { /* fall back to a supported task or upgrade package */ }","preventionTips":["Pin Microsoft.ML.AutoML versions across services","Never cast raw ints to TaskKind","Validate config-driven task names against the supported list"],"tags":["unsupported","task","automl"],"backgroundTag":"unsupported-enum-value","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}