{"record":{"id":"c60fdea9c0015102","repo":"LykosAI/StabilityMatrix","slug":"model-not-selected","errorCode":null,"errorMessage":"Model not selected","messagePattern":"Model not selected","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs","lineNumber":1644,"sourceCode":"    private void ApplyRecommendedDefaults()\n    {\n        if (!HasRecommendedDefaults)\n            return;\n\n        RecommendedDefaultsRequested?.Invoke(ResolvedWorkflowProfile);\n    }\n\n    private void SetupStandaloneModelLoader(ModuleApplyStepEventArgs e)\n    {\n        if (SelectedModelLoader is ModelLoader.Unet && IsGguf)\n        {\n            var checkpointLoader = e.Nodes.AddTypedNode(\n                new ComfyNodeBuilder.UnetLoaderGGUF\n                {\n                    Name = e.Nodes.GetUniqueName(nameof(ComfyNodeBuilder.UNETLoader)),\n                    UnetName =\n                        SelectedUnetModel?.RelativePath\n                        ?? throw new ValidationException(\"Model not selected\"),\n                }\n            );\n            e.Builder.Connections.Base.Model = checkpointLoader.Output;\n        }\n        else\n        {\n            var checkpointLoader = e.Nodes.AddTypedNode(\n                new ComfyNodeBuilder.UNETLoader\n                {\n                    Name = e.Nodes.GetUniqueName(nameof(ComfyNodeBuilder.UNETLoader)),\n                    UnetName =\n                        SelectedUnetModel?.RelativePath\n                        ?? throw new ValidationException(\"Model not selected\"),\n                    WeightDtype = SelectedDType ?? \"default\",\n                }\n            );\n            e.Builder.Connections.Base.Model = checkpointLoader.Output;\n        }","sourceCodeStart":1626,"sourceCodeEnd":1662,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs#L1626-L1662","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Select a unet/GGUF model in the model card dropdown before generating","Re-import or re-scan the checkpoint folder if the model file is missing from disk","Validate SelectedUnetModel != null before BuildPrompt and show a friendly 'choose a model' message","Persist the last selected model per workflow so it is restored on tab load"],"exampleFix":"// before\nUnetName = SelectedUnetModel?.RelativePath\n    ?? throw new ValidationException(\"Model not selected\"),\n\n// after (guard at call site)\nif (SelectedUnetModel is null)\n{\n    Logger.Warn(\"Generate aborted: no unet model selected\");\n    throw new ValidationException(\"Select a unet model in the model card before generating\");\n}\nvar checkpointLoader = e.Nodes.AddTypedNode(new ComfyNodeBuilder.UnetLoaderGGUF { UnetName = SelectedUnetModel.RelativePath, ... });","handlingStrategy":"validation","validationCode":"// Before generating\nif (modelCardVm.SelectedUnetModel is null)\n{\n    Logger.Warn(\"Cannot generate: no unet model selected\");\n    return;\n}","typeGuard":"bool HasSelectedModel(ModelCardViewModel card) =>\n    card.SelectedUnetModel is not null || card.SelectedCheckpoint is not null;","tryCatchPattern":"try\n{\n    await workflowVm.GenerateImageAsync();\n}\ncatch (ValidationException ex) when (ex.Message == \"Model not selected\")\n{\n    NotificationHelper.Warn(\"Select a unet/GGUF model in the model card before generating\");\n}","preventionTips":["Select a unet/GGUF model in the model card before generating GGUF workflows","Re-scan the checkpoint folder if models were moved or deleted on disk","Persist per-workflow model selections so they survive tab reloads","Verify the selected model still exists before building the prompt"],"tags":["model-selection","gguf","validation","comfyui"],"backgroundTag":"missing-required-argument","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}