herdrdev/herdr · warning · io::Error
{flag} must be greater than 0
Error message
{flag} must be greater than 0 What it means
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.
Source
Thrown at src/cli.rs:671
}
Ok(Ok(TerminalSessionOptions {
target: target.clone(),
cols,
rows,
takeover,
}))
}
fn parse_terminal_dimension(raw: &str, flag: &str) -> std::io::Result<u16> {
let parsed = raw.parse::<u16>().map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("{flag} must be an integer between 1 and {}", u16::MAX),
)
})?;
if parsed == 0 {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("{flag} must be greater than 0"),
));
}
Ok(parsed)
}
fn terminal_title(args: &[String]) -> std::io::Result<i32> {
match args.first().map(|arg| arg.as_str()) {
Some("set") => {
if args.len() != 2 {
eprintln!("usage: herdr terminal title set <title>");
return Ok(2);
}
print_response(&send_request(&Request {
id: "cli:terminal:title:set".into(),
method: Method::ClientWindowTitleSet(ClientWindowTitleSetParams {
title: args[1].clone(),View on GitHub (pinned to f457cff4f2)
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
Example fix
# before herdr session new --rows 0 --cols 80 # after herdr session new --rows 1 --cols 80
Defensive patterns
Strategy: validation
Validate before calling
let rows: u16 = args.rows.parse().unwrap_or(24);
if rows == 0 { return Err("rows must be >= 1".into()); } Prevention
- Never pass computed terminal sizes without a positive floor (max(1, n))
- Check that tput/terminal queries succeeded before using their output
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {flag} must be an integer between 1 and {}
- expected sha256 must be 64 hexadecimal characters
- {REMOTE_BINARY_ENV_VAR} path is not a file: {}
- api request line is too large
- timed out reading api request
AI-assisted analysis of herdrdev/herdr@f457cff4f2 (2026-08-28).
Data as JSON: /api/errors/eec0c1b47a49edbb.
Report an issue: GitHub.