LykosAI/StabilityMatrix · error · ValidationException

Sampler not selected

Error message

Sampler not selected

What it means

In Stability Matrix's ComfyUI inference workflow builder, WanSamplerCardViewModel.ApplyStep() reads the user-selected sampler from SelectedSampler and assigns it as the workflow's PrimarySampler. The property is nullable (ComfySampler?), so when nothing is selected the code throws a System.ComponentModel.DataAnnotations.ValidationException to abort workflow generation with a clear message instead of emitting a malformed ComfyUI graph.

Solutions

  1. Connect to a ComfyUI instance (check the Inference tab connection status) so the sampler list loads, then pick a sampler in the Wan sampler card dropdown before generating.
  2. Reopen the Inference tab or restart Stability Matrix so the sampler card re-initializes — the constructor defaults SelectedSampler to ComfySampler.UniPC.
  3. If constructing the card in code/tests, explicitly set SelectedSampler (e.g. card.SelectedSampler = ComfySampler.UniPC) before calling ApplyStep.
  4. Check that the sampler dropdown's ItemsSource binding is populated (ComfySamplers from IInferenceClientManager) if the null selection persists.

Example fix

// before (throws)
var primarySampler = SelectedSampler ?? throw new ValidationException("Sampler not selected");
// after (defensive default)
var primarySampler = SelectedSampler ?? ComfySampler.UniPC;
Defensive patterns

Strategy: validation

Validate before calling

if (card.SelectedSampler is null)
    throw new ValidationException("Select a sampler before generating.");
card.ApplyStep(e);

Type guard

bool HasSampler(WanSamplerCardViewModel c) => c.SelectedSampler is not null;

Try / catch

try { card.ApplyStep(e); }
catch (ValidationException ex) { NotifyUser(ex.Message); }

Prevention

When it happens

Trigger: Running a Wan image/video generation when WanSamplerCardViewModel.SelectedSampler is null at ApplyStep time — e.g. the sampler picker was never populated (ComfyUI client not connected / sampler list not loaded) or the bound selection was reset before the Generate button invoked the module pipeline.

Common situations: ComfyUI backend disconnected so available samplers never load into the dropdown; a saved prompt/layout was restored with a sampler value that no longer exists, leaving the selection null; a developer constructed WanSamplerCardViewModel manually (or via DI) and called ApplyStep without setting SelectedSampler; UI binding failure between the SamplerCard view and the view model.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/9ecb0447702cc46c. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Avalonia/ViewModels/Inference/WanSamplerCardViewModel.cs:48

        EnableAddons = false;
        IsLengthEnabled = true;
        SelectedSampler = ComfySampler.UniPC;
        SelectedScheduler = ComfyScheduler.Simple;
        Length = 33;
    }

    public override void ApplyStep(ModuleApplyStepEventArgs e)
    {
        if (EnableAddons)
        {
            foreach (var module in ModulesCardViewModel.Cards.OfType<ModuleBase>())
            {
                module.ApplyStep(e);
            }
        }

        // Set primary sampler and scheduler
        var primarySampler = SelectedSampler ?? throw new ValidationException("Sampler not selected");
        e.Builder.Connections.PrimarySampler = primarySampler;

        var primaryScheduler = SelectedScheduler ?? throw new ValidationException("Scheduler not selected");
        e.Builder.Connections.PrimaryScheduler = primaryScheduler;

        // for later inheritance if needed
        e.Builder.Connections.PrimaryCfg = CfgScale;
        e.Builder.Connections.PrimarySteps = Steps;
        e.Builder.Connections.PrimaryModelType = SelectedModelType;

        e.Temp = e.CreateTempFromBuilder();

        var conditioning = e.Temp.Base.Conditioning.Unwrap();

        var isImgToVid = IsDenoiseStrengthEnabled;

        if (isImgToVid)
        {

View on GitHub (pinned to af93d6ef57)