{"record":{"id":"051af6ab475d4527","repo":"LykosAI/StabilityMatrix","slug":"no-imagesource","errorCode":null,"errorMessage":"No ImageSource","messagePattern":"No ImageSource","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"warning","filePath":"StabilityMatrix.Avalonia/ViewModels/Inference/ControlNetCardViewModel.cs","lineNumber":114,"sourceCode":"            preprocessor is null\n            || SelectImageCardViewModel.ImageSource is not { } imageSource\n            || SelectImageCardViewModel.IsImageFileNotFound\n        )\n            return;\n\n        var args = new InferenceQueueCustomPromptEventArgs();\n\n        var images = SelectImageCardViewModel.GetInputImages();\n\n        await ClientManager.UploadInputImageAsync(imageSource);\n\n        var image = args.Nodes.AddTypedNode(\n            new ComfyNodeBuilder.LoadImage\n            {\n                Name = args.Nodes.GetUniqueName(\"Preprocessor_LoadImage\"),\n                Image =\n                    SelectImageCardViewModel.ImageSource?.GetHashGuidFileNameCached(\"Inference\")\n                    ?? throw new ValidationException(\"No ImageSource\")\n            }\n        ).Output1;\n\n        var aioPreprocessor = args.Nodes.AddTypedNode(\n            new ComfyNodeBuilder.AIOPreprocessor\n            {\n                Name = args.Nodes.GetUniqueName(\"Preprocessor\"),\n                Image = image,\n                Preprocessor = preprocessor.ToString(),\n                // AIO wants the lower of the two resolutions. who knows why.\n                // also why can't we put in the low/high thresholds?\n                // Or any of the other parameters for the other preprocessors?\n                Resolution = Math.Min(Width, Height)\n            }\n        );\n\n        args.Builder.Connections.OutputNodes.Add(\n            args.Nodes.AddTypedNode(","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Inference/ControlNetCardViewModel.cs#L96-L132","documentation":"PreviewPreprocessor in ControlNetCardViewModel builds a ComfyUI node graph for ControlNet preprocessing. It resolves the input image via SelectImageCardViewModel.ImageSource?.GetHashGuidFileNameCached(\"Inference\") and throws ValidationException(\"No ImageSource\") when the image card has no image selected, since the preprocessor pipeline cannot run without an input image.","triggerScenarios":"Clicking the ControlNet preview/preprocess button while the ControlNet card's SelectImageCardViewModel has ImageSource == null (no image dropped, selected, or loaded yet).","commonSituations":"Hitting preview before adding an input image to the ControlNet card; image failed to load earlier (bad file, cancelled import) leaving ImageSource unset; UI state reset after workflow changes.","solutions":["Add or select an input image on the ControlNet card before running the preprocessor preview","Disable the preview button in the UI while ImageSource is null","Catch ValidationException around preview invocation and show 'select an input image first' to the user"],"exampleFix":"// before\nImage = SelectImageCardViewModel.ImageSource?.GetHashGuidFileNameCached(\"Inference\")\n    ?? throw new ValidationException(\"No ImageSource\")\n\n// after (guard at call site)\nif (SelectImageCardViewModel.ImageSource is null)\n{\n    Logger.Warn(\"PreviewPreprocessor skipped: no image selected\");\n    return;\n}\nvar image = args.Nodes.AddTypedNode(new ComfyNodeBuilder.LoadImage { ... });","handlingStrategy":"validation","validationCode":"// Before invoking the preprocessor preview\nif (controlNetCardVm.SelectImageCardViewModel.ImageSource is null)\n{\n    Logger.Warn(\"Cannot preview preprocessor: no image selected\");\n    return;\n}","typeGuard":"bool HasControlNetImage(ControlNetCardViewModel card) =>\n    card.SelectImageCardViewModel?.ImageSource is not null;","tryCatchPattern":"try\n{\n    await controlNetCardVm.PreviewPreprocessor();\n}\ncatch (ValidationException ex) when (ex.Message == \"No ImageSource\")\n{\n    NotificationHelper.Warn(\"Select an input image on the ControlNet card first\");\n}","preventionTips":["Always load an input image into the ControlNet card before preprocessing","Disable the preview button while ImageSource is null","Verify the image finished importing (hash cached) before enabling preview","Check for a cleared ImageSource after workflow or tab resets"],"tags":["controlnet","validation","missing-image","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"}