opengovsg / postmangovsg

Templated message sending for public officers
https://postman.gov.sg
60 stars 16 forks source link

fix: prevent undefined params in govsg recipients frontend #2197

Closed jia1 closed 1 year ago

jia1 commented 1 year ago

https://open-government-products-re.sentry.io/issues/4411696399/?alert_rule_id=1124293&alert_type=issue&project=5261024&referrer=slack

jia1 commented 1 year ago

Can u use _.filter()? I think it's safe for null/undefined

Update: Yes, it'll work (https://codepen.io/travist/full/jrBjBz/)

~I tried reading the Lodash docs but can't get an idea of what _.filter returns if the arg is null/undefined. And the docs don't say whether it accepts null/undefined.~

~If you have a quick ans for ^ that'll be great. In the meantime, I'll check on my end.~

~The return value of params must be an array no matter what or the spread operator below will fail.~