api: firmware metrics parsing fix.

Skip trying to parse the FW metrics data when the file is empty.

BUG=b:267757300
TEST=run_tests

Change-Id: Ibd427c4ce83476c43b295ad47e2cb171db44fbdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4221635
Auto-Submit: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/firmware.py b/api/controller/firmware.py
index c601d96..f9e7d36 100644
--- a/api/controller/firmware.py
+++ b/api/controller/firmware.py
@@ -7,7 +7,7 @@
 Handle all firmware builder related functionality.  Currently no service module
 exists: all of the work is done here.
 """
-
+import logging
 import os
 import tempfile
 
@@ -62,10 +62,13 @@
             response = f.read()
 
     if metric_proto:
-        # Parse the entire metric file as our metric proto (as a passthru).
-        # TODO(b/177907747): BundleFirmwareArtifacts doesn't use this (yet?),
-        #   but firmware_builder.py requires it.
-        json_format.Parse(response, metric_proto)
+        if not response:
+            logging.warning("Metrics data empty.")
+        else:
+            # Parse the entire metric file as our metric proto (as a passthru).
+            # TODO(b/177907747): BundleFirmwareArtifacts doesn't use this
+            #   (yet?), but firmware_builder.py requires it.
+            json_format.Parse(response, metric_proto)
 
     if result.returncode == 0:
         return controller.RETURN_CODE_SUCCESS