{"record":{"id":"570093da03e4467d","repo":"herdrdev/herdr","slug":"flag-must-be-an-integer-between-1-and","errorCode":null,"errorMessage":"{flag} must be an integer between 1 and {}","messagePattern":"(.+?) must be an integer between 1 and (.+?)","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"src/cli.rs","lineNumber":665,"sourceCode":"            other => {\n                eprintln!(\"unknown terminal session {command} option: {other}\");\n                eprintln!(\"{usage}\");\n                return Ok(Err(2));\n            }\n        }\n    }\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>\");","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/herdrdev/herdr/blob/f457cff4f2648eee85d176f8a41861241d4e8428/src/cli.rs#L647-L683","documentation":"parse_terminal_dimension rejects CLI strings that cannot be parsed as a u16 (src/cli.rs:665). It is used for terminal size flags such as rows/columns on commands that open a terminal session. The error is io::ErrorKind::InvalidInput with a message naming the offending flag and the valid range 1..=65535.","triggerScenarios":"Passing --rows/--cols (or whichever terminal dimension flag) a non-numeric string, a negative number, a decimal like \"80.5\", or a value above 65535 to a CLI command parsed by parse_terminal_session_options.","commonSituations":"Typos in flags, passing an empty string from a shell variable, using expressions like $COLUMNS with stray whitespace, or scripts piping unset variables (\"\").","solutions":["Pass a plain integer between 1 and 65535, e.g. --rows 24 --cols 80","Quote and trim shell variables: --rows \"${ROWS:-24}\"","Validate dimension input in wrapper scripts before invoking herdr"],"exampleFix":"# before\nherdr session new --rows abc --cols 80\n\n# after\nherdr session new --rows 24 --cols 80","handlingStrategy":"validation","validationCode":"fn valid_dimension(s: &str) -> bool {\n    s.chars().all(|c| c.is_ascii_digit())\n        && s.parse::<u16>().map(|v| v >= 1).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default dimension env vars in scripts: ${ROWS:-24}","Reject non-numeric or zero dimensions in wrappers before calling the CLI"],"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"}