You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2024/09/19 20:07:33 UTC

(couchdb) branch fix-function-close-on-date-function-in-qjs-scanner created (now 7a540d06e)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch fix-function-close-on-date-function-in-qjs-scanner
in repository https://gitbox.apache.org/repos/asf/couchdb.git


      at 7a540d06e Handle the case when the QuickJS scanner has no valid views

This branch includes the following new commits:

     new 7a540d06e Handle the case when the QuickJS scanner has no valid views

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(couchdb) 01/01: Handle the case when the QuickJS scanner has no valid views

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch fix-function-close-on-date-function-in-qjs-scanner
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7a540d06e2e8509f5fa810c714072fab4e22f9d2
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Sep 19 16:05:23 2024 -0400

    Handle the case when the QuickJS scanner has no valid views
    
    Previously that particular design doc would crash it's validation with
    a function_clause in the logs which looked messy.
    
    To fix it, add a case statement to expect that they may not be any
    valid views left, so we just continue without complaints.
---
 src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl b/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl
index ed9ab91d3..c9fe96a2b 100644
--- a/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl
+++ b/src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl
@@ -247,10 +247,16 @@ views_validate(DDocId, #{?VIEWS := Views}, {Db, #st{} = St0}) when
     try
         lib_load(St, Views),
         ViewList = lists:sort(maps:to_list(valid_views(Views))),
-        Fun = fun({Name, #{?MAP := Src}}) -> add_fun_load(St, Name, Src) end,
-        lists:foreach(Fun, ViewList),
-        {[_ | _], St1 = #st{}} = lists:foldl(fun mapred_fold/2, {ViewList, St}, Docs),
-        {Db, St1}
+        case ViewList of
+            [_ | _] ->
+                Fun = fun({Name, #{?MAP := Src}}) -> add_fun_load(St, Name, Src) end,
+                lists:foreach(Fun, ViewList),
+                {[_ | _], St1 = #st{}} = lists:foldl(fun mapred_fold/2, {ViewList, St}, Docs),
+                {Db, St1};
+            [] ->
+                % There may be no valid views left
+                {Db, St}
+        end
     catch
         throw:{validate, Error} ->
             Meta = #{sid => SId, db => Db, ddoc => DDocId},