fix(billing): coerce COST_MULTIPLIER to a number before sandbox pricing
Merged
WA
2mo ago+60+60+01234567890123456789-6-6-0123456789
Summary
COST_MULTIPLIERis declared asz.number()butcreateEnvruns withskipValidation, so the value arrives as the rawprocess.envstring. Every existing consumer multiplies by it, which JS coerces silently, so the type bug was invisible untilcreateSandboxPricing(#7184) added aNumber.isFiniteguard — that guard rejects the string and every metered E2B/Daytona Function block fails withSandbox pricing multiplier must be a finite nonnegative numbergetCostMultipliernow normalizes the value throughenvNumber, the helper written for exactly this case. Unset, empty, non-numeric, and negative values fall back to 1 instead of leaking a string (or crashing) into billing math. This fixes all seven consumers at once- Regression tests exercise the real
getCostMultiplierunder a productionNODE_ENVwith a stringCOST_MULTIPLIER; they reproduce the exact error against the previous code
Type of Change
- Bug fix
Testing
- New tests fail on the previous code with the production error and pass with the fix
sandbox-pricing,cost-policy,providers/index, andenvsuites pass (84 tests)bun run lint, block-registry check,check:audits, and the CI env-flag validation block pass
Checklist
- Code follows project style guidelines
- Self-reviewed my changes
- Tests added/updated and passing
- No new warnings introduced
- I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)