agent: handle malformed metadata better

Change-Id: Ie5d2ad055cbea13490d04ec3589c32a3c08a5119
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1158925
Signed-off-by: Jiri Moskovcak <jmoskovc@redhat.com>
(cherry picked from commit cc5a96957fdc0b5c6ab59ceb26a9c5aa50614312)