LykosAI/StabilityMatrix · error · ValidationException
Sampler not selected
Error message
Sampler not selected
What it means
SamplerCardViewModel.ApplyStepsInitialCustomSampler throws this ValidationException when applying a custom-sampler step: SelectedSampler is null, so Connections.PrimarySampler cannot be set. The initial custom sampler step must define which ComfyUI sampler (e.g. euler, dpmpp_2m) to use, so it fails fast.
Solutions
- Choose a sampler in the sampler card's sampler dropdown before generating.
- Programmatically set vm.SelectedSampler to a valid ComfySampler value.
- Restore default sampler settings for the card to repopulate the selection.
- Guard generation: if SelectedSampler is null, surface a friendly prompt to pick one instead of letting the build throw.
Example fix
// before var samplerCard = new SamplerCardViewModel(); await samplerCard.ApplyStepsInitialCustomSampler(stepArgs); // throws // after var samplerCard = new SamplerCardViewModel(); samplerCard.SelectedSampler = ComfySampler.EulerAncestral; samplerCard.SelectedScheduler = ComfyScheduler.Karras; await samplerCard.ApplyStepsInitialCustomSampler(stepArgs);
Defensive patterns
Strategy: validation
Validate before calling
if (samplerCard.SelectedSampler is null)
throw new InvalidOperationException("Sampler must be selected before generation"); Type guard
var samplerReady = samplerCard.SelectedSampler is ComfySampler;
Try / catch
try { await samplerCard.ApplyStepsInitialCustomSampler(args); }
catch (ValidationException ex) when (ex.Message == "Sampler not selected")
{
// prompt user to choose a sampler
} Prevention
- Set a sensible default sampler when creating SamplerCardViewModel instances.
- Bind the sampler dropdown with a non-null default so it cannot remain empty.
- Validate sampler+scheduler together before invoking any ApplySteps method.
When it happens
Trigger: Running the workflow build path that calls ApplyStepsInitialCustomSampler with the sampler card's SelectedSampler property never set (no sampler chosen in the sampler card).
Common situations: User clears the sampler dropdown in the sampler card; a sampler pack/custom sampler selection failed to load so the default is null; programmatically constructing a SamplerCardViewModel without assigning SelectedSampler.
Understand the failure class
Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.
Related errors
- Scheduler not selected
- Length cannot be null when latentType is Hunyuan
- Prompt extensions not installed
- No ImageSource
- Model not selected
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/437d7c0717db8a98.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs:350
ModuleApplyStepEventArgs e,
bool useFluxGuidance,
bool useFlux2Scheduler = false
)
{
// Provide temp values
e.Temp = e.CreateTempFromBuilder();
// Apply steps from our addons
ApplyAddonSteps(e);
// Get primary as latent using vae
var primaryLatent = e.Builder.GetPrimaryAsLatent(
e.Temp.Primary!.Unwrap(),
e.Builder.Connections.GetDefaultVAE()
);
// 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;
// KSamplerSelect
var kSamplerSelect = e.Nodes.AddTypedNode(
new ComfyNodeBuilder.KSamplerSelect
{
Name = e.Nodes.GetUniqueName(nameof(ComfyNodeBuilder.KSamplerSelect)),
SamplerName = e.Builder.Connections.PrimarySampler?.Name!,
}
);View on GitHub (pinned to af93d6ef57)