From 62944467d097448197c1a38350a8267c0e63e6bc Mon Sep 17 00:00:00 2001 From: Bob Dionne Date: Mon, 11 Mar 2013 14:13:38 -0400 Subject: [PATCH] Better handling of null doc ids A null doc id causes fabric to throw an erlang error, this needs to be caught and handled in all doc calls. It returns error not_found to agree with couchdb. BugzID: 17496 --- src/fabric_view_all_docs.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fabric_view_all_docs.erl b/src/fabric_view_all_docs.erl index 8a4ed84..e69fbb2 100644 --- a/src/fabric_view_all_docs.erl +++ b/src/fabric_view_all_docs.erl @@ -169,8 +169,15 @@ doc_receive_loop(Keys, Pids, SpawnFun, MaxJobs, Callback, AccIn) -> doc_receive_loop(RKeys, Pids1, SpawnFun, MaxJobs, Callback, AccIn); _ -> {{value, {Pid, Ref}}, RestPids} = queue:out(Pids), - receive {'DOWN', Ref, process, Pid, #view_row{} = Row} -> - case Callback(fabric_view:transform_row(Row), AccIn) of + receive + {'DOWN', Ref, process, Pid, Reason} -> + case Reason of + #view_row{} = Row -> + NewRow = Row; + {{illegal_docid, Id}, _} -> + NewRow = #view_row{key = Id, doc = undefined} + end, + case Callback(fabric_view:transform_row(NewRow), AccIn) of {ok, Acc} -> doc_receive_loop( Keys, RestPids, SpawnFun, MaxJobs, Callback, Acc