[Bug]: roundToCurrencyPrecision accepts negative/NaN/null amounts without validation
Author: GeorgeS311578Created Sep 24, 2026Updated Sep 29, 2026
Labelsgood first issuetype: bugstatus: needs triagingversion: 2.0
Package.json file
N/ANode.js version
v24.13.0
Database and its version
N/A
Operating system name and version
Windows 11
Browser name
No response
What happended?
roundToCurrencyPrecision (payment-module.ts) never validates amount: negative, "NaN", NaN, null and unknown strings all return an object with precision instead of throwing. Whether bad values reach the DB depends on callers (e.g. captureService_.create), unaudited. Suggest validating/normalizing amount (and uppercasing currency like getSmallestUnit does) as defense in depth. Repro: call with the five inputs above, none throws
Expected behavior
Invalid amounts (negative, NaN, null, unknown strings) throw instead of returning precision.
Actual behavior
All five return an object with precision; nothing throws.
Link to reproduction repo
https://gist.github.com/GeorgeS311578/46553c71ec598e662198d3b873be5b4f
Source: medusajs/medusa