{"record":{"id":"8929bd106febdf88","repo":"Flow-Launcher/Flow.Launcher","slug":"invalid-svg-dimensions-height-must-be-greater-tha","errorCode":null,"errorMessage":"Invalid SVG dimensions: Height must be greater than zero in {path}","messagePattern":"Invalid SVG dimensions: Height must be greater than zero in (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"Flow.Launcher.Infrastructure/Image/ImageLoader.cs","lineNumber":518,"sourceCode":"        {\n            // Set up drawing settings\n            var desiredHeight = loadFullImage ? FullImageSize : SmallIconSize;\n            var drawingSettings = new WpfDrawingSettings\n            {\n                IncludeRuntime = true,\n                // Set IgnoreRootViewbox to false to respect the SVG's viewBox\n                IgnoreRootViewbox = false\n            };\n\n            // Load and render the SVG\n            var converter = new FileSvgReader(drawingSettings);\n            var drawing = converter.Read(new Uri(path));\n\n            // Calculate scale to achieve desired height\n            var drawingBounds = drawing.Bounds;\n            if (drawingBounds.Height <= 0)\n            {\n                throw new InvalidOperationException($\"Invalid SVG dimensions: Height must be greater than zero in {path}\");\n            }\n            var scale = desiredHeight / drawingBounds.Height;\n            var scaledWidth = drawingBounds.Width * scale;\n            var scaledHeight = drawingBounds.Height * scale;\n\n            // Convert the Drawing to a Bitmap\n            var drawingVisual = new DrawingVisual();\n            using (DrawingContext drawingContext = drawingVisual.RenderOpen())\n            {\n                drawingContext.PushTransform(new ScaleTransform(scale, scale));\n                drawingContext.DrawDrawing(drawing);\n            }\n\n            // Create a RenderTargetBitmap to hold the rendered image\n            var bitmap = new RenderTargetBitmap(\n                (int)Math.Ceiling(scaledWidth),\n                (int)Math.Ceiling(scaledHeight),\n                96, // DpiX","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/Flow-Launcher/Flow.Launcher/blob/7fc63b07bbaa10a0f0b2601487913fcba9ed24b0/Flow.Launcher.Infrastructure/Image/ImageLoader.cs#L500-L536","documentation":"Thrown as InvalidOperationException from LoadSvgImage when, after parsing the SVG with FileSvgReader, drawing.Bounds.Height is <= 0. The renderer cannot compute a scale factor (desiredHeight / 0 would be infinity/NaN) so rendering is aborted. This guards the subsequent RenderTargetBitmap creation which would otherwise throw or produce a degenerate image.","triggerScenarios":"An SVG with no explicit width/height and no viewBox (Bounds stays at 0,0,0,0); an SVG whose root element has width/height of 0 or negative; a malformed SVG that FileSvgReader partially parses leaving an empty Drawing; an SVG that uses only CSS-based sizing that the SVG renderer doesn't resolve.","commonSituations":"Plugin author ships an icon SVG exported with no dimensions; web-optimized SVG stripped of width/height attributes; an SVG referencing external resources that fail to load, collapsing the bounds; an SVG designed with percentage-based sizing only.","solutions":["Open the SVG in a browser/editor and confirm it renders with a real size.","Add explicit width and height (or a viewBox) attributes to the <svg> root element.","If the SVG is third-party, replace it with a version that declares dimensions or convert it to PNG.","Handle the failure upstream by catching InvalidOperationException in the image loader and falling back to a default icon."],"exampleFix":"// before\n<svg xmlns=\"http://www.w3.org/2000/svg\">...</svg>\n\n// after — declare a viewBox so the renderer computes bounds\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\">...</svg>","handlingStrategy":"try-catch","validationCode":"using var reader = XmlReader.Create(path);\nvar doc = XDocument.Load(reader);\nvar root = doc.Root;\nif (root?.Attribute(\"viewBox\") == null && root?.Attribute(\"width\") == null)\n    return LoadDefaultIcon();","typeGuard":"// Ensure the SVG root declares a viewBox or width/height\nstatic bool IsSvgRenderable(string path)\n{\n    var doc = XDocument.Load(path);\n    var svg = doc.Root;\n    return svg?.Attribute(\"viewBox\") != null\n        || (svg?.Attribute(\"width\") != null && svg?.Attribute(\"height\") != null);\n}","tryCatchPattern":"try { return LoadSvgImage(path); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"SVG dimensions\"))\n{ Log.Warn(ClassName, $\"Unrenderable SVG: {path}\"); return LoadDefaultIcon(); }","preventionTips":["Author icon SVGs with explicit width/height or a viewBox attribute.","Validate SVGs in an editor/browser before shipping them.","Provide a fallback PNG/icon for assets that fail to render.","Strip web-only percentage/CSS sizing from SVGs used as app icons."],"tags":["image","svg","rendering","validation"],"backgroundTag":null,"analyzedSha":"7fc63b07bbaa10a0f0b2601487913fcba9ed24b0","analyzedAt":"2026-08-13T14:54:20.914Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}