{"record":{"id":"d17b26d22d2ea4d7","repo":"spectreconsole/spectre.console","slug":"console-height-must-be-greater-than-zero","errorCode":null,"errorMessage":"Console height must be greater than zero","messagePattern":"Console height must be greater than zero","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Profile.cs","lineNumber":97,"sourceCode":"            {\n                throw new InvalidOperationException(\"Console width must be greater than zero\");\n            }\n\n            _width = value;\n        }\n    }\n\n    /// <summary>\n    /// Gets or sets an explicit console height.\n    /// </summary>\n    public int Height\n    {\n        get => _height ?? _out.Height;\n        set\n        {\n            if (value <= 0)\n            {\n                throw new InvalidOperationException(\"Console height must be greater than zero\");\n            }\n\n            _height = value;\n        }\n    }\n\n    /// <summary>\n    /// Gets or sets the capabilities of the profile.\n    /// </summary>\n    public Capabilities Capabilities\n    {\n        get => _capabilities;\n        set\n        {\n            _capabilities = value ?? throw new InvalidOperationException(\"Profile capabilities cannot be null\");\n        }\n    }\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Profile.cs#L79-L115","documentation":"Thrown by the Profile.Height setter when the value is <= 0. The same logic as the Width setter: Height is auto-detected from the terminal or explicitly overridden, and a non-positive value would corrupt layout (page breaks, progress bar positioning). The setter enforces > 0.","triggerScenarios":"Setting AnsiConsole.Profile.Height = 0 or a negative value. Also hit when height auto-detection returns 0 in a headless/CI environment and that value is passed to the setter.","commonSituations":"Running in CI without a TTY where terminal height detection returns 0; custom IAnsiConsoleOutput with Height = 0; misconfigured test harness passing zero height; redirecting stdout to a non-terminal.","solutions":["Clamp height to a minimum positive value: profile.Height = Math.Max(1, detectedHeight);","Use AnsiConsole.Testing.TestConsole with proper dimensions for tests.","In CI, set LINES env var or use a PTY so height detection returns positive.","Avoid setting Height explicitly when the terminal is available."],"exampleFix":"// before\nprofile.Height = ConsoleHelper.GetHeight(); // returns 0 headless\n\n// after\nvar detected = ConsoleHelper.GetHeight();\nprofile.Height = detected > 0 ? detected : 24; // safe default","handlingStrategy":"validation","validationCode":"// Clamp height to positive before setting\nvar height = detectedHeight > 0 ? detectedHeight : 24;\nAnsiConsole.Profile.Height = height;","typeGuard":"static bool IsValidConsoleDimension(int value) => value > 0;","tryCatchPattern":null,"preventionTips":["Do not set Height explicitly unless overriding.","In CI/headless, set LINES env var or use a PTY.","Clamp detected height: Math.Max(1, value) before assignment.","Use TestConsole with correct dimensions for tests."],"tags":["invalidoperationexception","profile","console-height","configuration","ci"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}