{"record":{"id":"58c9534c6a31083e","repo":"sharkdp/hexyl","slug":"block-size-argument-must-be-positive","errorCode":null,"errorMessage":"block size argument must be positive","messagePattern":"block size argument must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":305,"sourceCode":"            if filename.as_os_str() == \"-\" {\n                Input::Stdin(stdin.lock())\n            } else {\n                if filename.is_dir() {\n                    bail!(\"'{}' is a directory.\", filename.to_string_lossy());\n                }\n                let file = File::open(filename)?;\n\n                Input::File(file)\n            }\n        }\n        None => Input::Stdin(stdin.lock()),\n    };\n\n    if let Some(hex_number) = try_parse_as_hex_number(&opt.block_size) {\n        return hex_number\n            .map_err(|e| anyhow!(e))\n            .and_then(|x| {\n                PositiveI64::new(x).ok_or_else(|| anyhow!(\"block size argument must be positive\"))\n            })\n            .map(|_| ());\n    }\n    let (num, unit) = extract_num_and_unit_from(&opt.block_size)?;\n    if let Unit::Block { custom_size: _ } = unit {\n        return Err(anyhow!(\n            \"can not use 'block(s)' as a unit to specify block size\"\n        ));\n    };\n    let block_size = num\n        .checked_mul(unit.get_multiplier())\n        .ok_or_else(|| anyhow!(ByteOffsetParseError::UnitMultiplicationOverflow))\n        .and_then(|x| {\n            PositiveI64::new(x).ok_or_else(|| anyhow!(\"block size argument must be positive\"))\n        })?;\n\n    let skip_arg = opt\n        .skip","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/sharkdp/hexyl/blob/6ecc29b9c8c84d08a7e860f7f69c22b113b480ea/src/main.rs#L287-L323","documentation":"PositiveI64::new rejects non-positive values; when the hex-parsed block size is zero or negative, b3sum reports 'block size argument must be positive'.","triggerScenarios":"--block-size 0 or a hex expression evaluating to <= 0 (e.g. --block-size 0x0).","commonSituations":"Script variables defaulting to 0; computing sizes in shell arithmetic that yields 0; copy-pasting '0' as block size.","solutions":["Pass a block size of at least 1 byte, e.g. --block-size 1","Fix the shell variable/computation that yields 0","Validate the value before invoking: `[ \"$bs\" -gt 0 ] || exit 1`"],"exampleFix":"// before\nb3sum --block-size 0 file\n// after\nb3sum --block-size 4096 file","handlingStrategy":"validation","validationCode":"[ \"$bs\" -gt 0 ] 2>/dev/null || { echo 'block size must be > 0' >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate numeric args are > 0 in scripts","Avoid defaulting size vars to 0"],"tags":["cli","validation","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"6ecc29b9c8c84d08a7e860f7f69c22b113b480ea","analyzedAt":"2026-09-09T22:34:15.450Z","contentChangedAt":"2026-09-09T22:34:15.450Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}