LykosAI/StabilityMatrix · error · InvalidOperationException
: Model not selected
Error message
{Title}: Model not selected What it means
PromptExpansionModule.OnApplyStep() retrieves the PromptExpansionCardViewModel and reads its SelectedModel to build a ComfyNodeBuilder.PromptExpansion node. Because no prompt-expansion model is chosen, the module throws InvalidOperationException ("{Title}: Model not selected") to stop workflow generation rather than emitting a node with a null ModelName. Title is the module's display title, so the message identifies which Prompt Expansion card is misconfigured.
Solutions
- Open the Prompt Expansion card in the Inference tab and select a model from the dropdown before generating.
- If the dropdown is empty, download/install a compatible model via the Model Browser and verify the models directory (or shared ComfyUI folder) is configured in settings.
- Refresh the model list / restart the app so the installed model is indexed and appears in the picker.
- If building the module in code, set the card's SelectedModel before calling ApplyStep, or disable the Prompt Expansion module if not needed.
Example fix
// before
var model = promptExpansionCard.SelectedModel
?? throw new InvalidOperationException($"{Title}: Model not selected");
// after (caller-side guard)
if (promptExpansionCard.SelectedModel is null)
return; // or show a validation message instead of throwing mid-pipeline Defensive patterns
Strategy: validation
Validate before calling
if (module is PromptExpansionModule pe &&
pe.GetCard<PromptExpansionCardViewModel>().SelectedModel is null)
{
// disable module or prompt the user to pick a model before generating
} Type guard
bool HasExpansionModel(PromptExpansionCardViewModel c) => c.SelectedModel is not null;
Try / catch
try { module.ApplyStep(e); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Model not selected"))
{ ShowModelPickerDialog(); } Prevention
- Install at least one compatible prompt-expansion model and verify it appears in the card dropdown.
- Keep the shared ComfyUI models directory configured so installed models are always discovered.
- Disable the Prompt Expansion module when no model is available instead of leaving it enabled.
- Re-check SelectedModel after model uninstall/moves; refresh the model list before generating.
When it happens
Trigger: Clicking Generate with the Prompt Expansion module enabled but no model selected in its dropdown — either the user never picked a model, the model list is empty (no compatible models installed/indexed), or the previously selected model was uninstalled so SelectedModel reverted to null.
Common situations: Fresh install of Stability Matrix where no prompt-expansion model (e.g. a T5/CLIP-based expansion checkpoint) has been downloaded; the model file was moved or deleted from the models directory so it disappears from the picker; shared ComfyUI folder not configured so installed models aren't discovered; enabling the module via layout import without its model 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
- Sampler not selected
- Scheduler not selected
- BaseClipVision not set
- Client is not connected
- Prompt extensions not installed
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/f340acaef76c113a.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/ViewModels/Inference/Modules/PromptExpansionModule.cs:28
[ManagedService]
[RegisterTransient<PromptExpansionModule>]
public class PromptExpansionModule : ModuleBase
{
public PromptExpansionModule(IServiceManager<ViewModelBase> vmFactory)
: base(vmFactory)
{
Title = "Prompt Expansion";
AddCards(vmFactory.Get<PromptExpansionCardViewModel>());
}
protected override void OnApplyStep(ModuleApplyStepEventArgs e)
{
var promptExpansionCard = GetCard<PromptExpansionCardViewModel>();
var model =
promptExpansionCard.SelectedModel
?? throw new InvalidOperationException($"{Title}: Model not selected");
e.Builder.Connections.PositivePrompt = e.Nodes.AddTypedNode(
new ComfyNodeBuilder.PromptExpansion
{
Name = e.Nodes.GetUniqueName("PromptExpansion_Positive"),
ModelName = model.RelativePath,
Text = e.Builder.Connections.PositivePrompt,
Seed = e.Builder.Connections.Seed,
LogPrompt = promptExpansionCard.IsLogOutputEnabled
}
).Output;
}
}
View on GitHub (pinned to af93d6ef57)