Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.7.0
Description
E-mail from Alex Tang
mChefContext.getApi().deleteDatabagItem(DATABAG_NAME, databagItemName);
throws the following exception. Any insight why? The databag item was
delete propertly.
Thanks,
Alex
SEVERE: Error parsing input
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
databag item must be a json hash ex.
; was
{"name":"data_bag_item_cisco_packages_N3000-node1","json_class":"Chef::DataBagItem","chef_type":"data_bag_item","data_bag":"cisco_packages","raw_data":{"id":"N3000-node1","created_by":"alextang","packages":[
,
{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf23555.bin"},
{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf42365.bin"}],"location":"
ftp://10.2.3.4","creation_time":"Thursday, October 3, 2013 2:39:00 PM PDT"}}
at com.google.gson.Gson.fromJson(Gson.java:802)
at com.google.gson.Gson.fromJson(Gson.java:757)
at com.google.gson.Gson.fromJson(Gson.java:706)
at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:47)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:86)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:80)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:66)
at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:46)
at com.google.common.util.concurrent.Futures$3.apply(Futures.java:376)
at
com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:518)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalStateException: databag item must be a json
hash ex.
; was
{"name":"data_bag_item_cisco_packages_N3000-node1","json_class":"Chef::DataBagItem","chef_type":"data_bag_item","data_bag":"cisco_packages","raw_data":{"id":"N3000-node1","created_by":"alextang","packages":[
,
{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf23555.bin"},
{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf42365.bin"}],"location":"
ftp://10.2.3.4","creation_time":"Thursday, October 3, 2013 2:39:00 PM PDT"}}
at
com.google.common.base.Preconditions.checkState(Preconditions.java:176)
at
org.jclouds.chef.config.ChefParserModule$DataBagItemAdapter.createJsonLiteralFromRawJson(ChefParserModule.java:182)
at
org.jclouds.chef.config.ChefParserModule$DataBagItemAdapter.createJsonLiteralFromRawJson(ChefParserModule.java:176)
at
org.jclouds.json.internal.NullHackJsonLiteralAdapter.read(NullHackJsonLiteralAdapter.java:44)
at com.google.gson.Gson.fromJson(Gson.java:791)
... 12 more
Here is the re-creation snippet (groovy)
api.deleteDatabag("test")
Gson gson = new Gson()
api.createDatabag("test")
Properties config = new Properties()
config.setProperty("foo", "bar");
def databagItem = api.createDatabagItem("test", new DatabagItem("config", gson.toJson(config)))
def databagItemId = databagItem.getId()
assertEquals(databagItem.getId(), "config");
databagItem = api.getDatabagItem("test", databagItemId)
assertEquals(databagItem.getId(), "config");
databagItem = api.deleteDatabagItem("test", databagItemId)
assertEquals(databagItem.getId(), "config");
databagItem = api.getDatabagItem("test", databagItemId)
assertNull(databagItem)
Unfortunately we do not have a live test for this.