nickva commented on code in PR #5424:
URL: https://github.com/apache/couchdb/pull/5424#discussion_r1945572182


##########
src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl:
##########
@@ -814,12 +814,16 @@ nouveau_add_fun(#proc{}, _) ->
     ok.
 
 clouseau_index_doc(#proc{} = Proc, {[_ | _]} = Doc) ->
-    [Fields | _] = prompt(Proc, [<<"index_doc">>, Doc]),
-    lists:sort(Fields).
+    case prompt(Proc, [<<"index_doc">>, Doc]) of
+        [Fields | _] -> lists:sort(Fields);
+        [] -> []
+    end.
 
 nouveau_index_doc(#proc{} = Proc, {[_ | _]} = Doc) ->
-    [Fields | _] = prompt(Proc, [<<"nouveau_index_doc">>, Doc]),
-    lists:sort(Fields).
+    case prompt(Proc, [<<"nouveau_index_doc">>, Doc]) of
+        [Fields | _] -> lists:sort(Fields);
+        [] -> []
+    end.

Review Comment:
   There is a scanner test 
https://github.com/apache/couchdb/blob/dce6769edf141c36d408bddcd48082e91ae2f7ab/src/couch_quickjs/test/couch_quickjs_scanner_plugin_tests.erl#L430-L448
   
   But I don' think we officially documented the prompts in 
https://docs.couchdb.org/en/stable/query-server/protocol.html or have any other 
spec test for it.
   
   Speaking of spec tests, we do have them but I don't know if anyone has tried 
to run them int the last few years: 
https://github.com/apache/couchdb/blob/1bf03897e575112d1b401d3f98d52f28efc5dbaf/Makefile#L305-L308
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to