tinyhumansai/openhuman · error
Estimated cost must be a finite, non-negative value
Error message
Estimated cost must be a finite, non-negative value
What it means
A numeric-sanity guard on estimated cost values passed to the cost tracker: the value is either NaN, infinite, or negative, so it is rejected before being recorded. This fires when an upstream pricing calculation produces a non-finite result (division by zero in a per-token rate, a deserialized NaN from a provider payload) or a negative one — recording it would corrupt budget accounting, so the tracker fails closed.
Source
Thrown at src/openhuman/platform/cost/tracker.rs:72
/// Check if a request is within budget.
///
/// Only **managed-route** spend is considered (#5016). The local `[cost]`
/// limits cap spend against OpenHuman credits; bring-your-own-key and
/// local inference is billed by the user's own provider, so counting it
/// here produced a phantom limit — a pure-BYOK user accrued locally
/// *estimated* spend they were never charged for and got "You're out of
/// credits" at the default $10/day. See [`super::route`].
///
/// A pure-BYOK user therefore has zero managed spend and can never trip
/// this gate. Real managed-credit exhaustion is unaffected: it is enforced
/// server-side by the backend, which returns its own billing error.
pub fn check_budget(&self, estimated_cost_usd: f64) -> Result<BudgetCheck> {
if !self.config.enabled {
return Ok(BudgetCheck::Allowed);
}
if !estimated_cost_usd.is_finite() || estimated_cost_usd < 0.0 {
return Err(anyhow!(
"Estimated cost must be a finite, non-negative value"
));
}
let mut storage = self.lock_storage();
let (daily_cost, monthly_cost) = storage.get_aggregated_managed_costs()?;
// The all-routes totals exist purely to make the managed-vs-BYOK split
// visible in a debug log. `tracing` evaluates field expressions eagerly,
// so compute them only when that level is actually enabled rather than
// on every budget check in production.
if tracing::enabled!(tracing::Level::DEBUG) {
let (daily_all, monthly_all) = storage.get_aggregated_costs()?;
tracing::debug!(
daily_managed_usd = daily_cost,
monthly_managed_usd = monthly_cost,
daily_all_routes_usd = daily_all,
monthly_all_routes_usd = monthly_all,
daily_limit_usd = self.config.daily_limit_usd,View on GitHub (pinned to 7491200858)
Solutions
- Trace where the estimate originates — a provider returning garbage usage/pricing numbers is the usual source
- If computing cost locally, guard the arithmetic (per-token rates divided by zero token counts are a classic cause)
- Reject or clamp bad provider payloads at the ingestion boundary rather than passing them into the tracker
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/openhuman/platform/cost/tracker.rs:72 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17).
Data as JSON: /api/errors/574c887eaf208446.
Report an issue: GitHub.