{"record":{"id":"05e02eb469485827","repo":"rivo/tview","slug":"invalid-minimum-row-column-size","errorCode":null,"errorMessage":"Invalid minimum row/column size","messagePattern":"Invalid minimum row/column size","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"grid.go","lineNumber":143,"sourceCode":"// all row and column values are set to the given size values. See\n// [Grid.SetColumns] for details on sizes.\nfunc (g *Grid) SetSize(numRows, numColumns, rowSize, columnSize int) *Grid {\n\tg.rows = make([]int, numRows)\n\tfor index := range g.rows {\n\t\tg.rows[index] = rowSize\n\t}\n\tg.columns = make([]int, numColumns)\n\tfor index := range g.columns {\n\t\tg.columns[index] = columnSize\n\t}\n\treturn g\n}\n\n// SetMinSize sets an absolute minimum width for rows and an absolute minimum\n// height for columns. Panics if negative values are provided.\nfunc (g *Grid) SetMinSize(row, column int) *Grid {\n\tif row < 0 || column < 0 {\n\t\tpanic(\"Invalid minimum row/column size\")\n\t}\n\tg.minHeight, g.minWidth = row, column\n\treturn g\n}\n\n// SetGap sets the size of the gaps between neighboring primitives on the grid.\n// If borders are drawn (see SetBorders()), these values are ignored and a gap\n// of 1 is assumed. Panics if negative values are provided.\nfunc (g *Grid) SetGap(row, column int) *Grid {\n\tif row < 0 || column < 0 {\n\t\tpanic(\"Invalid gap size\")\n\t}\n\tg.gapRows, g.gapColumns = row, column\n\treturn g\n}\n\n// SetBorders sets whether or not borders are drawn around grid items. Setting\n// this value to true will cause the gap values (see SetGap()) to be ignored and","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/rivo/tview/blob/c15b79fa47f27032f26647a75cb5a81720255076/grid.go#L125-L161","documentation":"tview's Grid.SetMinSize panics immediately when either the row or column argument is negative. The library treats a negative minimum size as a programmer error rather than a recoverable condition, so it fails fast with this panic instead of clamping. Minimum sizes only make sense as non-negative absolute cell dimensions.","triggerScenarios":"Calling grid.SetMinSize(row, column) with a negative value for either argument, e.g. SetMinSize(-1, 0) or passing a computed value that underflowed to negative (such as height - padding when padding > height).","commonSituations":"Computing the minimum from user input, layout math, or config values without clamping; subtracting margins/padding from a dimension that can be smaller than the subtraction; copying a call from another widget where -1 means 'auto' (Grid has no such convention).","solutions":["Ensure both arguments are >= 0 before calling SetMinSize; clamp with max(0, value) if the value is computed.","If 'no minimum' is desired, pass 0 for that axis — do not pass a negative sentinel.","Check where the negative number originates (user config, subtraction, off-by-one) and fix the source computation.","If the value comes from user input, validate it before constructing the layout and report a friendly message instead of crashing."],"exampleFix":"// before\ngrid.SetMinSize(minHeight, minWidth) // minHeight may be -1 after padding subtraction\n// after\nif minHeight < 0 { minHeight = 0 }\nif minWidth < 0 { minWidth = 0 }\ngrid.SetMinSize(minHeight, minWidth)","handlingStrategy":"validation","validationCode":"func safeSetMinSize(g *tview.Grid, row, col int) *tview.Grid {\n    if row < 0 { row = 0 }\n    if col < 0 { col = 0 }\n    return g.SetMinSize(row, col)\n}","typeGuard":"func validMinSize(row, col int) bool { return row >= 0 && col >= 0 }","tryCatchPattern":"func() {\n    defer func() {\n        if r := recover(); r != nil && r == \"Invalid minimum row/column size\" {\n            log.Printf(\"SetMinSize rejected: %v\", r)\n        }\n    }()\n    grid.SetMinSize(row, col)\n}()","preventionTips":["Clamp any computed dimension with max(0, v) before calling SetMinSize.","Never use -1 as a sentinel with tview Grid APIs — 0 means 'no minimum'.","Validate user/config-supplied sizes at load time, before building layouts.","Add a unit test asserting layout builders never pass negatives."],"tags":["panic","tview","layout","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"c15b79fa47f27032f26647a75cb5a81720255076","analyzedAt":"2026-09-07T09:42:56.840Z","contentChangedAt":"2026-09-07T09:42:56.840Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}