{"record":{"id":"131cc330e2db80da","repo":"LykosAI/StabilityMatrix","slug":"flux-kontext-unet-model-not-found","errorCode":null,"errorMessage":"Flux Kontext UNET model not found","messagePattern":"Flux Kontext UNET model not found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/Services/FluxKontextModelManager.cs","lineNumber":173,"sourceCode":"                _ => model.FileName,\n            };\n            yield return name;\n        }\n    }\n\n    /// <summary>\n    /// Select the best available models for Flux Kontext (only selects LOCAL models)\n    /// </summary>\n    internal FluxKontextWorkflowBuilder.SelectedModels SelectModels(IInferenceClientManager clientManager)\n    {\n        var unetModel =\n            clientManager.UnetModels.FirstOrDefault(m =>\n                m.Local != null\n                && (\n                    m.FileName.Contains(\"flux1-dev-kontext\", StringComparison.OrdinalIgnoreCase)\n                    || m.FileName.Contains(\"flux-kontext\", StringComparison.OrdinalIgnoreCase)\n                )\n            ) ?? throw new InvalidOperationException(\"Flux Kontext UNET model not found\");\n\n        var vaeModel =\n            clientManager.VaeModels.FirstOrDefault(m =>\n                m.Local != null && m.FileName.Equals(\"ae.safetensors\", StringComparison.OrdinalIgnoreCase)\n            ) ?? throw new InvalidOperationException(\"Flux VAE model not found\");\n\n        var clip1Model =\n            clientManager.ClipModels.FirstOrDefault(m =>\n                m.Local != null && m.FileName.Contains(\"clip_l\", StringComparison.OrdinalIgnoreCase)\n            ) ?? throw new InvalidOperationException(\"CLIP-L model not found\");\n\n        var clip2Model =\n            clientManager.ClipModels.FirstOrDefault(m =>\n                m.Local != null\n                && (\n                    m.FileName.Contains(\"t5xxl\", StringComparison.OrdinalIgnoreCase)\n                    || m.FileName.Contains(\"t5-xxl\", StringComparison.OrdinalIgnoreCase)\n                )","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Services/FluxKontextModelManager.cs#L155-L191","documentation":"FluxKontextModelManager.SelectModels searches clientManager.UnetModels for a locally installed Flux Kontext checkpoint (filename containing 'flux1-dev-kontext' or 'flux-kontext'). If none is present with a Local file, it throws this InvalidOperationException because the Kontext workflow cannot be assembled.","triggerScenarios":"Calling SelectModels when no UnetModels entry has Local != null and a filename containing 'flux1-dev-kontext' or 'flux-kontext' (case-insensitive) — the Kontext UNET was never downloaded or isn't indexed.","commonSituations":"User runs the Kontext workflow before downloading flux1-dev-kontext_dev.safetensors; model in a folder not scanned by ComfyUI; file renamed so the substring match fails.","solutions":["Download a Flux Kontext UNET (e.g. flux1-dev-kontext_dev.safetensors) into the diffusion_models folder and refresh the index","Rename/move the existing file so its name contains 'flux-kontext' in a scanned folder","Catch InvalidOperationException and prompt the user with a one-click download of the Kontext UNET"],"exampleFix":"// before\nvar models = fluxKontextModelManager.SelectModels();\n// after\nif (!clientManager.UnetModels.Any(m => m.Local != null && m.FileName.Contains(\"flux-kontext\", StringComparison.OrdinalIgnoreCase)))\n{\n    throw new UserDownloadableError(\"Flux Kontext UNET is not installed. Download it first.\");\n}\nvar models = fluxKontextModelManager.SelectModels();","handlingStrategy":"validation","validationCode":"var unet = clientManager.UnetModels.FirstOrDefault(m => m.Local != null\n    && (m.FileName.Contains(\"flux1-dev-kontext\", StringComparison.OrdinalIgnoreCase)\n        || m.FileName.Contains(\"flux-kontext\", StringComparison.OrdinalIgnoreCase)));\nif (unet is null) throw new UserDownloadableError(\"Flux Kontext UNET is not installed.\");","typeGuard":"bool HasLocalKontextUnet(IEnumerable<HybridModelFile> models) => models.Any(m => m.Local != null && m.FileName.Contains(\"flux-kontext\", StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try\n{\n    var models = fluxKontextModelManager.SelectModels();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Kontext UNET model not found\"))\n{\n    // trigger Kontext UNET download flow\n}","preventionTips":["Verify all four Kontext components (UNET, VAE, CLIP-L, T5) before SelectModels","Avoid renaming downloaded model files","Refresh the model index after downloads"],"tags":["comfyui","models","flux-kontext"],"backgroundTag":"resource-not-found","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"}