LykosAI/StabilityMatrix · error · ValidationException

Model not selected

Error message

Model not selected

What it means

In ModelCardViewModel's prompt-building path, when the selected model is a GGUF unet, the graph uses ComfyNodeBuilder.UnetLoaderGGUF with UnetName taken from SelectedUnetModel?.RelativePath. If no unet checkpoint model is selected, it throws ValidationException("Model not selected") because the loader node has no model file to load.

Solutions

  1. Select a unet/GGUF model in the model card dropdown before generating
  2. Re-import or re-scan the checkpoint folder if the model file is missing from disk
  3. Validate SelectedUnetModel != null before BuildPrompt and show a friendly 'choose a model' message
  4. Persist the last selected model per workflow so it is restored on tab load

Example fix

// before
UnetName = SelectedUnetModel?.RelativePath
    ?? throw new ValidationException("Model not selected"),

// after (guard at call site)
if (SelectedUnetModel is null)
{
    Logger.Warn("Generate aborted: no unet model selected");
    throw new ValidationException("Select a unet model in the model card before generating");
}
var checkpointLoader = e.Nodes.AddTypedNode(new ComfyNodeBuilder.UnetLoaderGGUF { UnetName = SelectedUnetModel.RelativePath, ... });
Defensive patterns

Strategy: validation

Validate before calling

// Before generating
if (modelCardVm.SelectedUnetModel is null)
{
    Logger.Warn("Cannot generate: no unet model selected");
    return;
}

Type guard

bool HasSelectedModel(ModelCardViewModel card) =>
    card.SelectedUnetModel is not null || card.SelectedCheckpoint is not null;

Try / catch

try
{
    await workflowVm.GenerateImageAsync();
}
catch (ValidationException ex) when (ex.Message == "Model not selected")
{
    NotificationHelper.Warn("Select a unet/GGUF model in the model card before generating");
}

Prevention

When it happens

Trigger: Generating a prompt whose ModelCardViewModel is in GGUF/unet mode while SelectedUnetModel is null — e.g. the model dropdown was never populated, the model file was deleted/moved, or the checkpoint failed to import.

Common situations: Using a GGUF workflow without downloading/selecting the unet model; model files removed from disk after selection; a checkpoint manager refresh clearing SelectedUnetModel; base-model change resetting the selection.

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/c60fdea9c0015102. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs:1644

    private void ApplyRecommendedDefaults()
    {
        if (!HasRecommendedDefaults)
            return;

        RecommendedDefaultsRequested?.Invoke(ResolvedWorkflowProfile);
    }

    private void SetupStandaloneModelLoader(ModuleApplyStepEventArgs e)
    {
        if (SelectedModelLoader is ModelLoader.Unet && IsGguf)
        {
            var checkpointLoader = e.Nodes.AddTypedNode(
                new ComfyNodeBuilder.UnetLoaderGGUF
                {
                    Name = e.Nodes.GetUniqueName(nameof(ComfyNodeBuilder.UNETLoader)),
                    UnetName =
                        SelectedUnetModel?.RelativePath
                        ?? throw new ValidationException("Model not selected"),
                }
            );
            e.Builder.Connections.Base.Model = checkpointLoader.Output;
        }
        else
        {
            var checkpointLoader = e.Nodes.AddTypedNode(
                new ComfyNodeBuilder.UNETLoader
                {
                    Name = e.Nodes.GetUniqueName(nameof(ComfyNodeBuilder.UNETLoader)),
                    UnetName =
                        SelectedUnetModel?.RelativePath
                        ?? throw new ValidationException("Model not selected"),
                    WeightDtype = SelectedDType ?? "default",
                }
            );
            e.Builder.Connections.Base.Model = checkpointLoader.Output;
        }

View on GitHub (pinned to af93d6ef57)