{"record":{"id":"4830d3c61dd11cef","repo":"can1357/oh-my-pi","slug":"invalid-block-size-argument-0","errorCode":null,"errorMessage":"invalid --block-size argument '{0}'","messagePattern":"invalid --block-size argument '(.+?)'","errorType":"error_code","errorClass":"LsError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/ls.rs","lineNumber":3702,"sourceCode":"\t\tErrorKind::NotADirectory => format!(\"cannot access {}: Not a directory\", .0.quote()),\n\t\tErrorKind::NotFound => format!(\"cannot access {}: No such file or directory\", .0.quote()),\n\t\tErrorKind::PermissionDenied => match .1.raw_os_error().unwrap_or(1) {\n\t\t\t1 => format!(\"cannot access {}: Operation not permitted\", .0.quote()),\n\t\t\t_ => if *.3 {\n\t\t\t\tformat!(\"cannot open directory {}: Permission denied\", .0.quote())\n\t\t\t} else {\n\t\t\t\tformat!(\"cannot open file {}: Permission denied\", .0.quote())\n\t\t\t},\n\t\t},\n\t\t_ => if 9 == .1.raw_os_error().unwrap_or(1) {\n\t\t\tformat!(\"cannot open directory {}: Bad file descriptor\", .0.quote())\n\t\t} else {\n\t\t\tformat!(\"unknown io error: {}, '{:?}'\", .0.quote(), .1)\n\t\t},\n\t})]\n\tIOErrorContext(PathBuf, std::io::Error, bool, bool),\n\n\t#[error(\"invalid --block-size argument '{0}'\")]\n\tBlockSizeParseError(String),\n\n\t#[error(\"--dired and --zero are incompatible\")]\n\tDiredAndZeroAreIncompatible,\n\n\t#[error(\"{}: not listing already-listed directory\", .0.maybe_quote())]\n\tAlreadyListedError(PathBuf),\n\n\t#[error(\"invalid --time-style argument {}\\nPossible values are:\\n  - [posix-]full-iso\\n  - [posix-]long-iso\\n  - [posix-]iso\\n  - [posix-]locale\\n  - +FORMAT (e.g., +%H:%M) for a 'date'-style format\\n\\nFor more information try --help\", .0.quote())]\n\tTimeStyleParseError(String),\n}\n\nimpl LsError {\n\tfn code(&self) -> i32 {\n\t\tmatch self {\n\t\t\tSelf::InvalidLineWidth(_) => 2,\n\t\t\tSelf::IOError(_) => 1,\n\t\t\tSelf::IOErrorContext(_, _, false, _) => 1,","sourceCodeStart":3684,"sourceCodeEnd":3720,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/ls.rs#L3684-L3720","documentation":"LsError::BlockSizeParseError is raised by the builtin `ls` when the value passed to --block-size cannot be parsed as a valid size (a number optionally followed by a unit suffix like K/M/G). The library mirrors GNU coreutils behavior, which rejects malformed SIZE strings before any listing happens. It is a pure argument-validation error, not an I/O failure.","triggerScenarios":"Running the ls builtin with a --block-size value that is non-numeric, empty, has an unknown unit suffix (e.g. '12Q'), or a malformed combination like 'K1024'.","commonSituations":"Hand-typed CLI flags with typos ('--block-size=1OMB' instead of '1MB'), shell variables expanding to empty or whitespace, scripts ported between tools with different size-suffix conventions.","solutions":["Pass a valid size: an integer optionally followed by K, M, G, T, P, E, Z, Y (e.g. --block-size=1M)","Check for typos or stray characters in the flag value (`echo [-n \"$BLOCK_SIZE\"]` to spot hidden whitespace)","Omit --block-size entirely to use the default block sizing","If the value comes from an env var like BLOCK_SIZE or POSIXLY-correct wrappers, verify its contents"],"exampleFix":"// before\nls --block-size=1OMB\n// after\nls --block-size=1M","handlingStrategy":"validation","validationCode":"const VALID = /^\\d+(?:[KMGTPEZY](?:B)?)?$/i;\nif (blockSize !== undefined && !VALID.test(blockSize)) {\n  throw new RangeError(`invalid --block-size '${blockSize}': use e.g. 1, 512, 1M`);\n}","typeGuard":"const isBlockSize = (v: string): boolean => /^\\d+([KMGTPEZY]B?)?$/i.test(v);","tryCatchPattern":"try {\n  await Bun.$`ls --block-size=${bs} ${dir}`.quiet().nothrow();\n} catch (e) {\n  if (String(e).includes('invalid --block-size')) { /* fix arg and retry */ }\n  throw e;\n}","preventionTips":["Validate size flags with a regex before invoking","Never interpolate untrimmed env vars into --block-size","Prefer known-good literals like 1M/1G in scripts","Keep unit suffixes uppercase and canonical"],"tags":["cli","argument-validation","ls"],"backgroundTag":"invalid-cli-argument","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}