astrid-runtime/astrid · error
empty byte specifier
Error message
empty byte specifier
What it means
Input validation at the top of parse_bytes: the byte-size specifier, after trimming, is an empty string. The parser requires a numeric value plus optional suffix (e.g. 32, 32KB, 32MiB); an empty CLI value for a quota set operation has no meaning and is rejected before suffix parsing. A generic validation bail.
Source
Thrown at crates/astrid-cli/src/commands/quota.rs:338
let body = client
.request(AdminRequestKind::QuotaSet {
principal: target.clone(),
quotas,
})
.await?;
let _ = into_result(body)?;
println!("Updated quotas for '{target}'.");
Ok(ExitCode::SUCCESS)
}
// ── byte/duration parsers ──────────────────────────────────────────
/// Parse `"32"`, `"32B"`, `"32KB"`, `"32MB"`, `"32GB"`, `"32KiB"`,
/// `"32MiB"`, `"32GiB"`, `"32TB"`, `"32TiB"`. Lowercase accepted.
pub(crate) fn parse_bytes(s: &str) -> Result<u64> {
let trimmed = s.trim();
if trimmed.is_empty() {
anyhow::bail!("empty byte specifier");
}
// Strip optional `/s` (used by --ipc-rate).
let body = trimmed.strip_suffix("/s").unwrap_or(trimmed);
let (num_part, mult) = parse_numeric_suffix(body)?;
let num: f64 = num_part
.parse()
.with_context(|| format!("not a number: {num_part}"))?;
if num.is_sign_negative() || !num.is_finite() {
anyhow::bail!("byte value must be non-negative and finite");
}
#[expect(
clippy::cast_sign_loss,
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
reason = "guarded by sign and finite checks above"
)]
let bytes = (num * (mult as f64)) as u64;
Ok(bytes)View on GitHub (pinned to affd8760f4)
Solutions
- Supply a non-empty value with a unit, e.g. `--storage 10GB`
- Check shell variables/config files for empty values before invoking the command
- Quote and default variables: `${QUOTA:-10GB}`
Example fix
// before astrid quota set --storage "" // after astrid quota set --storage 10GB
Defensive patterns
Strategy: validation
Validate before calling
fn ensure_non_empty(s: &str) -> Result<&str, String> {
let t = s.trim();
if t.is_empty() { Err("byte specifier must not be empty".into()) } else { Ok(t) }
} Prevention
- Use shell parameter defaults (${VAR:-10GB}) for quota inputs
- Validate config-file fields are non-empty before passing to CLI
- Never interpolate possibly-empty env vars directly into flags
When it happens
Trigger: Passing an empty or whitespace-only value to `--storage`, `--ipc-rate`, or another byte-parsed quota flag.
Common situations: An unset environment variable expanded to empty in a shell script (`--storage "$QUOTA"` with QUOTA=""), a config file with a blank field, or accidentally passing `--storage ""`.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- byte value must be non-negative and finite
- --retain-entries must be at least 1
- --retain-bytes must be greater than 0
- --var has an empty key (got {item:?})
- --var '{key}' was supplied more than once
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/e85403f682060107.
Report an issue: GitHub.