{"record":{"id":"103cfde96f103215","repo":"spectreconsole/spectre.console","slug":"ratio-must-be-equal-to-or-greater-than-1","errorCode":null,"errorMessage":"Ratio must be equal to or greater than 1","messagePattern":"Ratio must be equal to or greater than 1","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Widgets/Layout/Layout.cs","lineNumber":34,"sourceCode":"    /// Gets or sets the name.\n    /// </summary>\n    public string? Name { get; set; }\n\n    /// <summary>\n    /// Gets or sets the ratio.\n    /// </summary>\n    /// <remarks>\n    /// Defaults to <c>1</c>.\n    /// Must be greater than <c>0</c>.\n    /// </remarks>\n    public int Ratio\n    {\n        get => _ratio;\n        set\n        {\n            if (value < 1)\n            {\n                throw new InvalidOperationException(\"Ratio must be equal to or greater than 1\");\n            }\n\n            _ratio = value;\n        }\n    }\n\n    /// <summary>\n    /// Gets or sets the minimum width.\n    /// </summary>\n    /// <remarks>\n    /// Defaults to <c>1</c>.\n    /// Must be greater than <c>0</c>.\n    /// </remarks>\n    public int MinimumSize\n    {\n        get => _minimumSize;\n        set\n        {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Widgets/Layout/Layout.cs#L16-L52","documentation":"Thrown by the Layout.Ratio setter when the value is less than 1. Ratio controls how space is distributed among siblings; a zero or negative ratio is meaningless so it must be at least 1.","triggerScenarios":"Setting Layout.Ratio to 0 or a negative integer, including via object initializer or fluent builder.","commonSituations":"Computing ratios from weights that can be zero, or resetting a ratio to 0 intending to hide the layout (use IsVisible=false instead).","solutions":["Set Ratio to a value >= 1.","Use Math.Max(1, ratio) when ratios are computed.","To hide a layout, set IsVisible = false rather than Ratio = 0."],"exampleFix":"// before\nlayout.Ratio = computedWeight; // could be 0\n\n// after\nlayout.Ratio = Math.Max(1, computedWeight);\n// or to hide: layout.IsVisible = false;","handlingStrategy":"validation","validationCode":"if (ratio < 1) throw new ArgumentOutOfRangeException(nameof(ratio), \"Ratio must be >= 1\");\nlayout.Ratio = ratio;","typeGuard":"static bool IsValidRatio(int value) => value >= 1;","tryCatchPattern":null,"preventionTips":["Use IsVisible=false to hide layouts instead of Ratio=0.","Clamp computed weights with Math.Max(1, value)."],"tags":["layout","invalid-operation","property-validation","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}