api: handle case where metadata is None

This fixes bug #1158808

Change-Id: Ib63f42417262544b12f3cdf267d3c2f2eb47746a
Signed-off-by: Julien Danjou <julien@danjou.info>
Merge "api: handle case where metadata is None"