buffet: Report command instance parsing error to cloud server

When a command comes from GCD server and fails to parse, we used to
just skip the command without reporting anything to the server.

This lead to the same command coming down in the next fetch cycle and
be retried over and over again.

Now if buffet cannot process a command, we mark it as "aborted" on the
server and provide actual failure reason - in the "error" property of
the command resource.

BUG=brillo:952
TEST=`FEATURES=test emerge-buffet`
     Tested manually on device through GCD dev site.

Change-Id: Idcda5ca296696a01d7e008f148f125c1a4ed1072
Reviewed-on: https://chromium-review.googlesource.com/268442
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_instance.h b/buffet/commands/command_instance.h
index f67b30b..6ce7036 100644
--- a/buffet/commands/command_instance.h
+++ b/buffet/commands/command_instance.h
@@ -63,10 +63,15 @@
   // object, checking the JSON |value| against the command definition schema
   // found in command |dictionary|. On error, returns null unique_ptr and
   // fills in error details in |error|.
+  // |command_id| is the ID of the command returned, as parsed from the |value|.
+  // The command ID extracted (if present in the JSON object) even if other
+  // parsing/validation error occurs and command instance is not constructed.
+  // This is used to report parse failures back to the server.
   static std::unique_ptr<CommandInstance> FromJson(
       const base::Value* value,
       const std::string& origin,
       const CommandDictionary& dictionary,
+      std::string* command_id,
       chromeos::ErrorPtr* error);
 
   // Returns JSON representation of the command.