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


##########
src/couch/src/couch_server.erl:
##########
@@ -92,7 +93,12 @@ get_stats() ->
     [{start_time, ?l2b(Time)}, {dbs_open, Open}].
 
 get_js_engine() ->
-    list_to_binary(config:get("couchdb", "js_engine", ?COUCHDB_JS_ENGINE)).
+    Engine = config:get("couchdb", "js_engine", ?COUCHDB_JS_ENGINE),
+    % If user misconfigured it by accident, don't crash, use defaults
+    case lists:member(Engine, ?AVAILABLE_JS_ENGINES) of
+        true -> list_to_binary(Engine);
+        false -> list_to_binary(?COUCHDB_JS_ENGINE)

Review Comment:
   Hmm
   
   `(node1@127.0.0.1)4> config:set("couchdb", "js_engine", "wrong_engine").`  
   
   should have resulted in the default being returned
   
   ```
   (node1@127.0.0.1)4> config:set("couchdb", "js_engine", "wrong_engine").
   ok
   (node1@127.0.0.1)5> couch_server:get_js_engine().
   <<"spidermonkey">>
   ```
   
   Did you re-run make at the top level, wonder if the module didn't compile 
properly...
   
   There is no good place to log it from since it all takes place in 
config:set/3. Doing it in `couch_server:get_js_engine()` might not be a good 
idea as that's called from the welcome endpoint so we wouldn't want to log 
errors every call there since it's completely un-authenticated. With the 
welcome endpoint returning the non-default the users should be able to figure 
out if the setting took effect or not



-- 
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