{"record":{"id":"b988de09dfbcfc1c","repo":"LykosAI/StabilityMatrix","slug":"model-not-selected-wanmodelcardviewmodel","errorCode":null,"errorMessage":"Model not selected","messagePattern":"Model not selected","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/ViewModels/Inference/WanModelCardViewModel.cs","lineNumber":182,"sourceCode":"            );\n            await dialog.ShowAsync();\n            return false;\n        }\n\n        return true;\n    }\n\n    public void ApplyStep(ModuleApplyStepEventArgs e)\n    {\n        ComfyTypedNodeBase<ModelNodeConnection> modelLoader;\n        if (SelectedModel?.RelativePath.EndsWith(\"gguf\", StringComparison.OrdinalIgnoreCase) is true)\n        {\n            modelLoader = e.Nodes.AddTypedNode(\n                new ComfyNodeBuilder.UnetLoaderGGUF\n                {\n                    Name = e.Nodes.GetUniqueName(nameof(ComfyNodeBuilder.UnetLoaderGGUF)),\n                    UnetName =\n                        SelectedModel?.RelativePath ?? throw new ValidationException(\"Model not selected\"),\n                }\n            );\n        }\n        else\n        {\n            modelLoader = e.Nodes.AddTypedNode(\n                new ComfyNodeBuilder.UNETLoader\n                {\n                    Name = e.Nodes.GetUniqueName(nameof(ComfyNodeBuilder.UNETLoader)),\n                    UnetName =\n                        SelectedModel?.RelativePath ?? throw new ValidationException(\"Model not selected\"),\n                    WeightDtype = SelectedDType ?? \"fp8_e4m3fn_fast\",\n                }\n            );\n        }\n        \n        var modelSamplingSd3 = e.Nodes.AddTypedNode(\n            new ComfyNodeBuilder.ModelSamplingSD3","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Inference/WanModelCardViewModel.cs#L164-L200","documentation":"Stability Matrix's Inference workflow builder throws ValidationException when the Wan workflow's UNet loader node is created but no model has been selected in the WanModelCard UI. For GGUF checkpoints it uses SelectedModel?.RelativePath, which is null when no checkpoint is chosen, so it throws 'Model not selected'. This is a deliberate fail-fast validation so an incomplete workflow is never sent to ComfyUI.","triggerScenarios":"Clicking generate/apply a Wan inference workflow while the UNet/GGUF model dropdown in the WanModelCardViewModel has no selection (SelectedModel == null), so SelectedModel?.RelativePath evaluates to null at WanModelCardViewModel.cs:182.","commonSituations":"User adds a Wan image/video generation workflow and forgets to pick a unet/diffusion-model file; the selected model was moved or deleted from the shared model folder after the card remembered its path; a preset or imported workflow references a model that no longer resolves to a selection.","solutions":["Open the Wan model card in the Inference tab and select a unet/diffusion model (gguf or safetensors) before generating.","Click the folder/refresh icon on the model dropdown to rescan the shared model directory if the expected model is missing.","Place the model file in the correct ComfyUI shared unet/diffusion_models folder so it appears in the picker.","If a saved workflow triggers this, reopen it after confirming the model is indexed, or re-pick the model and save."],"exampleFix":"// before\nUnetName = SelectedModel?.RelativePath ?? throw new ValidationException(\"Model not selected\")\n// after\n// in the ViewModel, before ApplyStep builds nodes:\nif (SelectedModel is null)\n    throw new ValidationException(\"Model not selected\"); // surfaced in UI before node building\nUnetName = SelectedModel.RelativePath;","handlingStrategy":"validation","validationCode":"if (card.SelectedModel is null) throw new ValidationException(\"Model not selected\");","typeGuard":"bool HasModel(WanModelCardViewModel c) => c.SelectedModel is { RelativePath: not null };","tryCatchPattern":"catch (ValidationException ex) when (ex.Message == \"Model not selected\") { /* prompt for model */ }","preventionTips":["Disable generate until all required dropdowns are set"],"tags":["comfyui","workflow-validation","stable-diffusion","model-selection"],"backgroundTag":"missing-required-option","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"}