dotnet/machinelearning · error · NotImplementedException

{nameof(ChannelMessageKind)}.{e.Kind} is not yet implemented

Error message

{nameof(ChannelMessageKind)}.{e.Kind} is not yet implemented.

What it means

RelayCurrentContextLogsToLogger maps channel messages to logger calls by ChannelMessageKind. A new/unhandled kind reaches the default branch, so the library throws NotImplementedException because it has no logging strategy for that message kind.

Source

Thrown at src/Microsoft.ML.AutoML/Experiment/Experiment.cs:111

        {
            // Relay logs that are generated by the current MLContext to the Experiment class's
            // _logger.
            switch (e.Kind)
            {
                case ChannelMessageKind.Trace:
                    _logger.Trace(e.Message);
                    break;
                case ChannelMessageKind.Info:
                    _logger.Info(e.Message);
                    break;
                case ChannelMessageKind.Warning:
                    _logger.Warning(e.Message);
                    break;
                case ChannelMessageKind.Error:
                    _logger.Error(e.Message);
                    break;
                default:
                    throw new NotImplementedException($"{nameof(ChannelMessageKind)}.{e.Kind} is not yet implemented.");
            }
        }

        public IList<TRunDetail> Execute()
        {
            var iterationResults = new List<TRunDetail>();
            // Create a timer for the max duration of experiment. When given time has
            // elapsed, MaxExperimentTimeExpiredEvent is called to interrupt training
            // of current model. Timer is not used if no experiment time is given, or
            // is not a positive number.
            if (_experimentSettings.MaxExperimentTimeInSeconds > 0)
            {
                _maxExperimentTimeTimer = new Timer(
                    new TimerCallback(MaxExperimentTimeExpiredEvent), null,
                    _experimentSettings.MaxExperimentTimeInSeconds * 1000, Timeout.Infinite
                );
            }
            // If given max duration of experiment is 0, only 1 model will be trained.

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Update Microsoft.ML.AutoML / ML.NET to a version where the switch covers your ChannelMessageKind values.
  2. Catch NotImplementedException around experiment execution and log the raw message instead of crashing.
  3. If custom channel code is in play, only emit kinds the switch handles (Progress, Warning, Error).

Example fix

// before
case ChannelMessageKind.Error:
    _logger.Error(e.Message);
    break;
// after
case ChannelMessageKind.Error:
    _logger.Error(e.Message);
    break;
case ChannelMessageKind.Progress:
    _logger.Log(LogLevel.Information, e.Message);
    break;
Defensive patterns

Strategy: try-catch

Validate before calling

if (!Enum.IsDefined(typeof(ChannelMessageKind), e.Kind) || e.Kind == ChannelMessageKind.Progress)
    // ensure switch handles all kinds before relaying

Type guard

bool IsHandled(ChannelMessageKind k) => k is ChannelMessageKind.Progress or ChannelMessageKind.Error;

Try / catch

try { experiment.Execute(); }
catch (NotImplementedException ex) { _logger.LogWarning($"Unhandled channel message kind: {ex.Message}"); }

Prevention

When it happens

Trigger: AutoML experiment's message channel delivers a ChannelMessage whose Kind is neither Progress nor Error (e.g. a newly added ChannelMessageKind enum value from a newer ML.NET channel implementation) while experiment logs are being relayed to ILogger.

Common situations: Running AutoML with a custom or upgraded IChannel/ILogger setup where message kinds outside Warning/Error/Progress are emitted; version drift between the channel enum and Experiment's switch.

Related errors


AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11). Data as JSON: /api/errors/9ef3a83131dfaeb6. Report an issue: GitHub.