{"record":{"id":"eec0c1b47a49edbb","repo":"herdrdev/herdr","slug":"flag-must-be-greater-than-0","errorCode":null,"errorMessage":"{flag} must be greater than 0","messagePattern":"(.+?) must be greater than 0","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"src/cli.rs","lineNumber":671,"sourceCode":"    }\n\n    Ok(Ok(TerminalSessionOptions {\n        target: target.clone(),\n        cols,\n        rows,\n        takeover,\n    }))\n}\n\nfn parse_terminal_dimension(raw: &str, flag: &str) -> std::io::Result<u16> {\n    let parsed = raw.parse::<u16>().map_err(|_| {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            format!(\"{flag} must be an integer between 1 and {}\", u16::MAX),\n        )\n    })?;\n    if parsed == 0 {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            format!(\"{flag} must be greater than 0\"),\n        ));\n    }\n    Ok(parsed)\n}\n\nfn terminal_title(args: &[String]) -> std::io::Result<i32> {\n    match args.first().map(|arg| arg.as_str()) {\n        Some(\"set\") => {\n            if args.len() != 2 {\n                eprintln!(\"usage: herdr terminal title set <title>\");\n                return Ok(2);\n            }\n            print_response(&send_request(&Request {\n                id: \"cli:terminal:title:set\".into(),\n                method: Method::ClientWindowTitleSet(ClientWindowTitleSetParams {\n                    title: args[1].clone(),","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/herdrdev/herdr/blob/f457cff4f2648eee85d176f8a41861241d4e8428/src/cli.rs#L653-L689","documentation":"parse_terminal_dimension parses a u16 successfully but then rejects the value 0 (src/cli.rs:671), because a zero-sized terminal is meaningless. It returns io::ErrorKind::InvalidInput with '{flag} must be greater than 0'. Note that a literal \"0\" parses fine as u16, so only this second check catches it.","triggerScenarios":"Passing exactly 0 to a terminal dimension flag (e.g. --rows 0 or --cols 0) on a command parsed by parse_terminal_session_options. Values like \"-1\" or \"abc\" fail earlier with the range message from error 11.","commonSituations":"Unset numeric env vars defaulting to 0, arithmetic in scripts producing 0 (e.g. $(tput lines) failing), or attempting to create a hidden/minimal pane.","solutions":["Pass a positive integer (>= 1) for every dimension flag","Default unset shell variables explicitly: --rows \"${ROWS:-24}\"","Debug wrapper scripts that compute dimensions from tput/terminal size queries"],"exampleFix":"# before\nherdr session new --rows 0 --cols 80\n\n# after\nherdr session new --rows 1 --cols 80","handlingStrategy":"validation","validationCode":"let rows: u16 = args.rows.parse().unwrap_or(24);\nif rows == 0 { return Err(\"rows must be >= 1\".into()); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass computed terminal sizes without a positive floor (max(1, n))","Check that tput/terminal queries succeeded before using their output"],"tags":["cli","validation","argument-parsing","rust"],"backgroundTag":"invalid-cli-argument","analyzedSha":"f457cff4f2648eee85d176f8a41861241d4e8428","analyzedAt":"2026-08-28T15:41:09.197Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}