LykosAI/StabilityMatrix · error · ValidationException

No SelectedModel

Error message

No SelectedModel

What it means

ControlNetModule.OnApplyStep throws this ValidationException when constructing the ComfyNodeBuilder.ControlNetLoader node: card.SelectedModel is null, so there is no ControlNet model relative path to load. The module cannot wire a ControlNetApplyAdvanced node without a model, so it fails fast before emitting the graph.

Solutions

  1. Pick a ControlNet model in the ControlNet card's model selector before generating.
  2. Install/import a matching ControlNet model (e.g. matching the base model and preprocessor type) and select it.
  3. Programmatically set card.SelectedModel to a valid HybridModelFile whose RelativePath exists under the ControlNet models folder.
  4. Disable the ControlNet module if it is not needed.
  5. Verify the model file still exists on disk, since a missing file can clear the selection.

Example fix

// before
controlNetCard.SelectImageCardViewModel.ImageSource = img; // model unset
await vm.Generate();
// after
controlNetCard.SelectImageCardViewModel.ImageSource = img;
controlNetCard.SelectedModel = controlNetModelFile;
await vm.Generate();
Defensive patterns

Strategy: validation

Validate before calling

if (controlNetCard.SelectedModel is null)
    throw new InvalidOperationException("ControlNet requires a model selection");

Type guard

var hasControlNetModel = controlNetCard.SelectedModel?.RelativePath is not null;

Try / catch

try { await vm.Generate(); }
catch (ValidationException ex) when (ex.Message == "No SelectedModel")
{
    // prompt user to pick a ControlNet model
}

Prevention

When it happens

Trigger: Including a ControlNet module in the pipeline while the ControlNet card's model dropdown (SelectedModel) is unset or holds no installed ControlNet model.

Common situations: User enables the ControlNet toggle and selects an image but never picks a ControlNet model; the selected model file was deleted/moved so the card's selection reset to null; programmatically constructed module wired with only an image and preprocessor.

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


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

Appendix: source

Thrown at StabilityMatrix.Avalonia/ViewModels/Inference/Modules/ControlNetModule.cs:155

            }
            e.Temp.Primary = controlNetReferenceOnly.Output2;

            // Indicate that the Primary latent has been temp batched
            // https://github.com/comfyanonymous/ComfyUI_experiments/issues/11

            e.Temp.IsPrimaryTempBatched = true;
            // Index 0 is the original image, index 1 is the reference only latent
            e.Temp.PrimaryTempBatchPickIndex = 1;

            return;
        }

        var controlNetLoader = e.Nodes.AddTypedNode(
            new ComfyNodeBuilder.ControlNetLoader
            {
                Name = e.Nodes.GetUniqueName("ControlNetLoader"),
                ControlNetName =
                    card.SelectedModel?.RelativePath ?? throw new ValidationException("No SelectedModel"),
            }
        );

        var controlNetApply = e.Nodes.AddTypedNode(
            new ComfyNodeBuilder.ControlNetApplyAdvanced
            {
                Name = e.Nodes.GetUniqueName("ControlNetApply"),
                Image = image,
                ControlNet = controlNetLoader.Output,
                Positive = e.Temp.Base.Conditioning!.Unwrap().Positive,
                Negative = e.Temp.Base.Conditioning.Negative,
                Strength = card.Strength,
                StartPercent = card.StartPercent,
                EndPercent = card.EndPercent,
            }
        );

        e.Temp.Base.Conditioning = (controlNetApply.Output1, controlNetApply.Output2);

View on GitHub (pinned to af93d6ef57)