BUG: POST /assets no input validation for duration — NaN stored when absent #69
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
In
services/mam-api/src/routes/assets.js:82:If
req.body.durationis""(empty string), JavaScript treats""as falsy, so it correctly falls tonull. But ifreq.body.durationis0(which should mean "zero-length clip"), it's also falsy and becomesnull.More importantly, if
durationis an arbitrary non-number type that is truthy (e.g."abc"),Math.round("abc" * 1000)=NaN, andNaNgets stored intoduration_msas a PostgresNaNvalue (postgres actually roundsNaNtoNULLwhen the column isBIGINT, but this depends on driver behavior).Impact
NaNduration stored in the DB can cause issues in JS-side calculations later (e.g.,NaN < 5isfalse)duration=0(possible with a zero-frame recording that wasn't caught by theemptycheck), the asset getsduration_ms=NULLinstead of0Location
services/mam-api/src/routes/assets.js:82Fix