{"record":{"id":"d824ed79f39e95e7","repo":"dotnet/machinelearning","slug":"the-trainer-node-name-is-not-handled-currently","errorCode":null,"errorMessage":"The trainer '{node.Name}' is not handled currently.","messagePattern":"The trainer '(.+?)' is not handled currently\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.CodeGenerator/CodeGenerator/CSharp/TrainerGeneratorFactory.cs","lineNumber":80,"sourceCode":"                    case TrainerName.SgdCalibratedBinary:\n                        return new SgdCalibratedBinary(node);\n                    case TrainerName.SymbolicSgdLogisticRegressionBinary:\n                        return new SymbolicSgdLogisticRegressionBinary(node);\n                    case TrainerName.Ova:\n                        return new OneVersusAll(node);\n                    case TrainerName.ImageClassification:\n                        return new ImageClassificationTrainer(node);\n                    case TrainerName.MatrixFactorization:\n                        return new MatrixFactorization(node);\n                    case TrainerName.LightGbmRanking:\n                        return new LightGbmRanking(node);\n                    case TrainerName.FastTreeRanking:\n                        return new FastTreeRanking(node);\n                    default:\n                        throw new ArgumentException($\"The trainer '{trainer}' is not handled currently.\");\n                }\n            }\n            throw new ArgumentException($\"The trainer '{node.Name}' is not handled currently.\");\n        }\n    }\n}\n","sourceCodeStart":62,"sourceCodeEnd":84,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.CodeGenerator/CodeGenerator/CSharp/TrainerGeneratorFactory.cs#L62-L84","documentation":"The second throw in TrainerGeneratorFactory.GetInstance: reached when Enum.TryParse(node.Name) fails, i.e. the pipeline node's trainer name is not even a member of the TrainerName enum. The factory therefore cannot map the node to any C# trainer generator and throws this ArgumentException with the raw node name in the message.","triggerScenarios":"Calling GetInstance with a PipelineNode whose Name string is misspelled, empty, or from a different ML.NET version than the TrainerName enum compiled into the CodeGenerator assembly (e.g. 'LightGbm' vs 'LightGbmBinary').","commonSituations":"Hand-built PipelineNode instances fed into the code generator; name drift after upgrading Microsoft.ML.AutoML so TrainerName members were renamed; custom pipelines serialized with legacy trainer names.","solutions":["Compare node.Name in the message to members of the Microsoft.ML.AutoML.TrainerName enum and fix the pipeline node to use the exact enum member name.","Verify the CodeGenerator and AutoML package versions match; align NuGet package versions.","Add the trainer to the TrainerName enum and the factory switch if you control the source.","Wrap GetInstance in a try-catch and fall back to a manual/echo pipeline when the trainer is unknown."],"exampleFix":"// before\nvar node = new PipelineNode { Name = \"LightGbm\" };\n// after\nvar node = new PipelineNode { Name = \"LightGbmBinary\" }; // exact TrainerName enum member","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(node.Name) ||\n    !Enum.TryParse<TrainerName>(node.Name, out _))\n    throw new InvalidOperationException($\"Unknown trainer name: '{node.Name}'\");","typeGuard":"static bool IsValidTrainerName(string name) =>\n    !string.IsNullOrEmpty(name) &&\n    Enum.IsDefined(typeof(TrainerName), name) && // parses via TryParse semantics\n    Enum.TryParse(name, out TrainerName _);","tryCatchPattern":"try\n{\n    return TrainerGeneratorFactory.GetInstance(node);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"not handled currently\"))\n{\n    return null; // fall back to manual handling\n}","preventionTips":["Always build PipelineNode.Name from TrainerName enum members via ToString(), never hand-typed strings.","Match CodeGenerator and AutoML package versions so TrainerName sets align.","Validate node names early in the conversion pipeline.","Add a unit test that round-trips every TrainerName member through the factory if you own the source."],"tags":["codegen","mlnet","unknown-trainer","enum-parse"],"backgroundTag":"invalid-enum-value","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}