{"action":"created","issue":{"url":"https://api.github.com/repos/cloudant/java-cloudant/issues/239","repository_url":"https://api.github.com/repos/cloudant/java-cloudant","labels_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/239/labels{/name}","comments_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/239/comments","events_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/239/events","html_url":"https://github.com/cloudant/java-cloudant/issues/239","id":147316569,"number":239,"title":"Failure when removing design documents (for indexes)","user":{"login":"stephen-kruger","id":7523054,"avatar_url":"https://avatars.githubusercontent.com/u/7523054?v=3","gravatar_id":"","url":"https://api.github.com/users/stephen-kruger","html_url":"https://github.com/stephen-kruger","followers_url":"https://api.github.com/users/stephen-kruger/followers","following_url":"https://api.github.com/users/stephen-kruger/following{/other_user}","gists_url":"https://api.github.com/users/stephen-kruger/gists{/gist_id}","starred_url":"https://api.github.com/users/stephen-kruger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephen-kruger/subscriptions","organizations_url":"https://api.github.com/users/stephen-kruger/orgs","repos_url":"https://api.github.com/users/stephen-kruger/repos","events_url":"https://api.github.com/users/stephen-kruger/events{/privacy}","received_events_url":"https://api.github.com/users/stephen-kruger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cloudant/java-cloudant/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cloudant/java-cloudant/milestones/8","html_url":"https://github.com/cloudant/java-cloudant/milestones/2.4.3","labels_url":"https://api.github.com/repos/cloudant/java-cloudant/milestones/8/labels","id":1689443,"number":8,"title":"2.4.3","description":"","creator":{"login":"ricellis","id":10698320,"avatar_url":"https://avatars.githubusercontent.com/u/10698320?v=3","gravatar_id":"","url":"https://api.github.com/users/ricellis","html_url":"https://github.com/ricellis","followers_url":"https://api.github.com/users/ricellis/followers","following_url":"https://api.github.com/users/ricellis/following{/other_user}","gists_url":"https://api.github.com/users/ricellis/gists{/gist_id}","starred_url":"https://api.github.com/users/ricellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricellis/subscriptions","organizations_url":"https://api.github.com/users/ricellis/orgs","repos_url":"https://api.github.com/users/ricellis/repos","events_url":"https://api.github.com/users/ricellis/events{/privacy}","received_events_url":"https://api.github.com/users/ricellis/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":1,"state":"open","created_at":"2016-04-07T13:44:29Z","updated_at":"2016-04-11T12:52:41Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-04-11T05:02:26Z","updated_at":"2016-04-11T21:29:35Z","closed_at":null,"body":"Cloudant 2.4.1\r\nUsing a previously suggested method to list design documents : \r\n```java\r\nList<String> designDocIds = database.getAllDocsRequestBuilder()\r\n                                    .startKey(\"_design/\")\r\n                                    .endKey(\"_design0\")\r\n                                    .build()\r\n                                    .getResponse()\r\n                                    .getDocIds();\r\n```\r\n\r\nI then remove each one using : \r\n`DesignDocumentManager ddm = database.getDesignDocumentManager();\r\nddm.remove(designDocId);`\r\n\r\nThis works fine for views etc, but when it hits a DD for Indexes, I get this error : \r\n```\r\ncom.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 133\r\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176)\r\n\tat com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)\r\n\tat com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:187)\r\n\tat com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145)\r\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)\r\n\tat com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)\r\n\tat com.google.gson.Gson.fromJson(Gson.java:803)\r\n\tat com.google.gson.Gson.fromJson(Gson.java:741)\r\n\tat com.cloudant.client.org.lightcouch.internal.CouchDbUtil.getResponse(CouchDbUtil.java:211)\r\n\tat com.cloudant.client.org.lightcouch.CouchDbClient.get(CouchDbClient.java:329)\r\n\tat com.cloudant.client.org.lightcouch.CouchDatabaseBase.find(CouchDatabaseBase.java:88)\r\n\tat com.cloudant.client.api.Database.find(Database.java:536)\r\n\tat com.cloudant.client.api.DesignDocumentManager.remove(DesignDocumentManager.java:154)```"},"comment":{"url":"https://api.github.com/repos/cloudant/java-cloudant/issues/comments/208571271","html_url":"https://github.com/cloudant/java-cloudant/issues/239#issuecomment-208571271","issue_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/239","id":208571271,"user":{"login":"stephen-kruger","id":7523054,"avatar_url":"https://avatars.githubusercontent.com/u/7523054?v=3","gravatar_id":"","url":"https://api.github.com/users/stephen-kruger","html_url":"https://github.com/stephen-kruger","followers_url":"https://api.github.com/users/stephen-kruger/followers","following_url":"https://api.github.com/users/stephen-kruger/following{/other_user}","gists_url":"https://api.github.com/users/stephen-kruger/gists{/gist_id}","starred_url":"https://api.github.com/users/stephen-kruger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephen-kruger/subscriptions","organizations_url":"https://api.github.com/users/stephen-kruger/orgs","repos_url":"https://api.github.com/users/stephen-kruger/repos","events_url":"https://api.github.com/users/stephen-kruger/events{/privacy}","received_events_url":"https://api.github.com/users/stephen-kruger/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T21:29:34Z","updated_at":"2016-04-11T21:29:34Z","body":"I changed my code to use your method, and no longer get the exception.\r\n```java\r\n\tpublic void removeDesignDocs(Database database) {\r\n\t\ttry {\r\n\t\t\tfor (Map.Entry<String, String> docInfo : database.getAllDocsRequestBuilder()\r\n\t\t\t\t\t.startKey(\"_design/\")\r\n\t\t\t\t\t.endKey(\"_design0\")\r\n\t\t\t\t\t.build()\r\n\t\t\t\t\t.getResponse()\r\n\t\t\t\t\t.getIdsAndRevs()\r\n\t\t\t\t\t.entrySet()) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tlog.info(\"Removing design doc {}\",docInfo.getKey());\r\n\t\t\t\t\tdatabase.getDesignDocumentManager().remove(docInfo.getKey(), docInfo.getValue());\r\n\t\t\t\t}\r\n\t\t\t\tcatch (Throwable t) {\r\n\t\t\t\t\tlog.error(\"Problem removing index {} {}\",docInfo.getKey(),docInfo.getValue(),t);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch (Throwable t) {\r\n\t\t\tlog.error(\"Problem removing design docs from db\",t);\r\n\t\t}\r\n\t}\r\n```\r\n\r\nI think this rules out an issue in my design doc."}}