Fix 500 when POSTing an empty list + prevent crash in case of invalid mongo operation

A POST with an empty array leads to a server crash. This fix returns a 400 error instead and ensure server won't crash in case of other mongo invalid operations.