Follow-on to 212944e1eae2ffb9a3e27ea7d1c6813160cce1ed for #1951.

- After events, check that metadata is valid.  If invalid, return empty array.
- Add unit tests to test cases of invalid files with valid extensions.