{"record":{"id":"2d8d0f74ec86c34e","repo":"dotnet/machinelearning","slug":"the-runner-metric-manager-is-of-type-metricmanag-2d8d0f","errorCode":null,"errorMessage":"The runner metric manager is of type {_metricManager.GetType()} which expected to be of type {typeof(ITrainValidateDatasetManager)} or {typeof(ICrossValidateDatasetManager)}","messagePattern":"The runner metric manager is of type (.+?) which expected to be of type (.+?) or (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.AutoML/API/RegressionExperiment.cs","lineNumber":450,"sourceCode":"                            var loss = metricManager.IsMaximize ? -metric : metric;\n\n                            stopWatch.Stop();\n\n\n                            return Task.FromResult(new TrialResult<RegressionMetrics>()\n                            {\n                                Loss = loss,\n                                Metric = metric,\n                                Metrics = metrics,\n                                Model = model,\n                                TrialSettings = settings,\n                                DurationInMilliseconds = stopWatch.ElapsedMilliseconds,\n                                Pipeline = refitPipeline,\n                            } as TrialResult);\n                        }\n                    }\n\n                    throw new ArgumentException($\"The runner metric manager is of type {_metricManager.GetType()} which expected to be of type {typeof(ITrainValidateDatasetManager)} or {typeof(ICrossValidateDatasetManager)}\");\n                }\n            }\n            catch (Exception ex) when (ct.IsCancellationRequested)\n            {\n                throw new OperationCanceledException(ex.Message, ex.InnerException);\n            }\n            catch (Exception)\n            {\n                throw;\n            }\n        }\n\n        public void Dispose()\n        {\n            _context.CancelExecution();\n            _context = null;\n        }\n","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.AutoML/API/RegressionExperiment.cs#L432-L468","documentation":"RegressionExperiment.RunAsync's evaluation loop dispatches on the type of _metricManager and only handles ITrainValidateDatasetManager and ICrossValidateDatasetManager. When the manager is another type, neither branch produces a TrialResult and control reaches the trailing throw of ArgumentException, indicating a misconfigured runner.","triggerScenarios":"Running a regression AutoML experiment whose metric/dataset manager object is neither ITrainValidateDatasetManager nor ICrossValidateDatasetManager (custom implementation or wrong object injected), so both switch branches are skipped and the terminal ArgumentException is hit.","commonSituations":"Hand-rolled AutoML runners; dependency-injection misconfiguration supplying a custom IDatasetManager; package version mismatch where runner interfaces were refactored.","solutions":["Construct the experiment through the standard builders so a TrainTestSplit (ITrainValidateDatasetManager) or CrossValidation (ICrossValidateDatasetManager) manager is used.","Make custom dataset managers implement one of the two expected interfaces.","Validate the manager type at experiment setup and throw early with a descriptive message.","Align all Microsoft.ML.AutoML package references to the same version."],"exampleFix":"// before\nexperiment.SetDataset(new MyDatasetManager(data)); // unsupported type\nawait experiment.RunAsync(ct);\n// after\nexperiment.SetDataset(new CrossValidationDatasetManager(data, numFolds: 5));\nawait experiment.RunAsync(ct);","handlingStrategy":"type-guard","validationCode":"// before RunAsync:\nif (_metricManager is not ITrainValidateDatasetManager and not ICrossValidateDatasetManager)\n    throw new InvalidOperationException(\"Use TrainTestSplit or CrossValidation dataset manager\");","typeGuard":"bool IsValidManager(object m) => m is ITrainValidateDatasetManager or ICrossValidateDatasetManager;","tryCatchPattern":"try { var best = await experiment.RunAsync(ct); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"metric manager\")) { // rebuild experiment with standard dataset manager\n    throw new InvalidOperationException(\"Regression experiment dataset manager misconfigured\", ex); }","preventionTips":["Build regression experiments through mlContext.Auto().CreateRegressionExperiment/StandardPipelines","Avoid custom IDatasetManager implementations unless they implement the expected interfaces","Add a construction-time assertion for the manager type"],"tags":["argument-exception","type-mismatch","automl","regression"],"backgroundTag":"type-mismatch","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"}