couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [2/2] couch-mrview commit: updated refs/heads/windsor-merge to 258abc4
Date Wed, 06 Aug 2014 10:38:53 GMT
Gracefully handle design document updates with malformatted structure


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/258abc4a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/258abc4a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/258abc4a

Branch: refs/heads/windsor-merge
Commit: 258abc4a13e8e3fb586d71c0843d6f5ed6a0ecf4
Parents: 5942d53
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Aug 6 11:34:25 2014 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Aug 6 11:34:25 2014 +0100

----------------------------------------------------------------------
 src/couch_mrview.erl | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/258abc4a/src/couch_mrview.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview.erl b/src/couch_mrview.erl
index 4c2de5f..22e9fbd 100644
--- a/src/couch_mrview.erl
+++ b/src/couch_mrview.erl
@@ -43,6 +43,15 @@
 
 
 validate(DbName, DDoc) ->
+    {Fields} = DDoc#doc.body,
+    case couch_util:get_value(<<"options">>, Fields, {[]}) of
+        {_} -> ok;
+        _ -> throw({invalid_design_doc, <<"`options` parameter must be an object.">>})
+    end,
+    case couch_util:get_value(<<"views">>, Fields, {[]}) of
+        {_} -> ok;
+        _ -> throw({invalid_design_doc, <<"`views` parameter must be an object.">>})
+    end,
     GetName = fun
         (#mrview{map_names = [Name | _]}) -> Name;
         (#mrview{reduce_funs = [{Name, _} | _]}) -> Name;


Mime
View raw message