BoundaryML/baml · error · LimitsError
combined normal and reserved capacity overflowed usize
Error message
combined normal and reserved capacity overflowed usize
What it means
`LimitsError::CapacityOverflow`. Adding the reserved byte capacity to the normal outbound byte capacity overflowed `usize`. The combined capacity is computed during validation and must fit in the platform's addressable integer range.
Source
Thrown at baml_language/crates/baml_lsp_server/src/lsp_ingress.rs:266
read_bytes: 2 * 1024 * 1024,
control_items: 64,
control_bytes: 64 * 1024,
outbound_response_items: 256,
outbound_response_bytes: 4 * 1024 * 1024,
response_reservation_bytes: 16 * 1024,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum LimitsError {
#[error("all ingress capacities and the response reservation must be non-zero")]
ZeroCapacity,
#[error("read capacity must fit inside normal capacity")]
ReadExceedsNormal,
#[error("one response reservation must fit in the outbound byte capacity")]
ResponseReservationTooLarge,
#[error("combined normal and reserved capacity overflowed usize")]
CapacityOverflow,
}
impl IngressLimits {
fn validate(self) -> Result<Self, LimitsError> {
if self.normal_items == 0
|| self.normal_bytes == 0
|| self.reserved_items == 0
|| self.reserved_bytes == 0
|| self.read_items == 0
|| self.read_bytes == 0
|| self.control_items == 0
|| self.control_bytes == 0
|| self.outbound_response_items == 0
|| self.outbound_response_bytes == 0
|| self.response_reservation_bytes == 0
{
return Err(LimitsError::ZeroCapacity);View on GitHub (pinned to bd85ce9dee)
Solutions
- Use realistic finite capacity values whose sum fits in usize
- Sanity-check and clamp configured limits to sane maximums before constructing
- Use checked arithmetic (checked_mul/checked_add) when deriving capacities from products
- Log the offending values; validate at startup to fail fast with this clear message
Example fix
// before: unbounded config value flows into limits
let normal = env_or("OUTBOUND_BYTES", usize::MAX);
let limits = IngressLimits::new(items, normal, read, reservation, normal)?;
// after: clamp before constructing
let normal = env_or("OUTBOUND_BYTES", 64 << 20).min(1 << 40);
let limits = IngressLimits::new(items, normal, read, reservation.min(normal), normal)?; Defensive patterns
Strategy: validation
Validate before calling
fn sums_fit(normal: usize, reserved: usize) -> bool { normal.checked_add(reserved).is_some() } Try / catch
let normal = normal.min(SANE_MAX); let reserved = reserved.min(SANE_MAX - normal); let limits = IngressLimits::new(items, normal, read, reserved.min(normal), normal + reserved)?;
Prevention
- Clamp config/env-provided capacities to sane maxima
- Use checked_mul/checked_add when deriving capacities from products
- Treat u64::MAX-style sentinels from config as errors, not values
When it happens
Trigger: Constructing `IngressLimits` with very large normal and reserved byte capacities whose sum exceeds `usize::MAX` (e.g. values parsed from user config near u64 max on 64-bit), then validating.
Common situations: Misconfigured 'huge' limits (e.g. u64::MAX from an env var) that overflow when combined; computing capacities via multiplication (n_items * max_msg) that wrapped before validation.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- all ingress capacities and the response reservation must be
- read capacity must fit inside normal capacity
- one response reservation must fit in the outbound byte capac
- class offset fits u32
- enum offset fits u32
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/6f77bda36bb1d797.
Report an issue: GitHub.