diff options
author | Will Young <lost.networking@gmail.com> | 2022-04-22 07:57:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 07:57:10 +0000 |
commit | e8146aa2efd252511d8385be33347c142c3bb7cf (patch) | |
tree | 2ee81d8cbd33adb5ac1e24de23ab301f3f50afba | |
parent | e87abefd09a03391ab2e5de15710ba4d2111c695 (diff) | |
parent | 8b9708ac7e45b4b10ae3c3fe9872d64f9aef1c1a (diff) | |
download | couchdb-e8146aa2efd252511d8385be33347c142c3bb7cf.tar.gz |
Merge branch '3.x' into nose2
-rw-r--r-- | share/server/filter.js | 2 | ||||
-rw-r--r-- | share/server/loop.js | 2 | ||||
-rw-r--r-- | share/server/render.js | 2 | ||||
-rw-r--r-- | share/server/util.js | 7 | ||||
-rw-r--r-- | share/server/views.js | 3 | ||||
-rw-r--r-- | src/chttpd/src/chttpd_misc.erl | 2 | ||||
-rw-r--r-- | src/couch/priv/couch_js/86/main.cpp | 2 | ||||
-rw-r--r-- | src/couch/src/couch_bt_engine.erl | 2 | ||||
-rw-r--r-- | src/dreyfus/src/dreyfus.erl | 31 | ||||
-rw-r--r-- | src/jwtf/src/jwtf.erl | 4 | ||||
-rw-r--r-- | src/jwtf/test/jwtf_tests.erl | 8 | ||||
-rw-r--r-- | src/mango/src/mango_idx.erl | 8 | ||||
-rw-r--r-- | src/mango/src/mango_native_proc.erl | 2 |
13 files changed, 53 insertions, 22 deletions
diff --git a/share/server/filter.js b/share/server/filter.js index ddb6479bb..84f5cfc09 100644 --- a/share/server/filter.js +++ b/share/server/filter.js @@ -30,7 +30,7 @@ var Filter = (function() { filter_view : function(fun, ddoc, args) { // recompile var sandbox = create_filter_sandbox(); - var source = fun.toSource ? fun.toSource() : '(' + fun.toString() + ')'; + var source = fun.toSource(); fun = evalcx(source, sandbox); var results = []; diff --git a/share/server/loop.js b/share/server/loop.js index 5d7738911..91dd1d6b0 100644 --- a/share/server/loop.js +++ b/share/server/loop.js @@ -133,7 +133,7 @@ var Loop = function() { } else if (e.name) { respond(["error", e.name, e]); } else { - respond(["error","unnamed_error",e.toSource ? e.toSource() : e.stack]); + respond(["error","unnamed_error", e.toSource()]); } }; while (line = readline()) { diff --git a/share/server/render.js b/share/server/render.js index 946701ef5..078a6491b 100644 --- a/share/server/render.js +++ b/share/server/render.js @@ -347,7 +347,7 @@ var Render = (function() { throw(e); } else { var logMessage = "function raised error: " + - (e.toSource ? e.toSource() : e.toString()) + " \n" + + e.toSource() + " \n" + "stacktrace: " + e.stack; log(logMessage); throw(["error", errType || "render_error", logMessage]); diff --git a/share/server/util.js b/share/server/util.js index 2a047cdf6..f570acebd 100644 --- a/share/server/util.js +++ b/share/server/util.js @@ -81,8 +81,7 @@ var Couch = { throw [ "error", "compilation_error", - "Module require('" +name+ "') raised error " + - (e.toSource ? e.toSource() : e.stack) + "Module require('" +name+ "') raised error " + e.toSource() ]; } ddoc._module_cache[newModule.id] = newModule.exports; @@ -107,7 +106,7 @@ var Couch = { throw([ "error", "compilation_error", - (err.toSource ? err.toSource() : err.stack) + " (" + source + ")" + err.toSource() + " (" + source + ")" ]); }; if (typeof(functionObject) == "function") { @@ -139,7 +138,7 @@ function respond(obj) { print(JSON.stringify(obj)); } catch(e) { log("Error converting object to JSON: " + e.toString()); - log("error on obj: "+ (obj.toSource ? obj.toSource() : obj.toString())); + log("error on obj: "+ obj.toSource()); } }; diff --git a/share/server/views.js b/share/server/views.js index 7c9953d83..32d65e457 100644 --- a/share/server/views.js +++ b/share/server/views.js @@ -74,8 +74,7 @@ var Views = (function() { // will kill the OS process. This is not normally what you want. throw(err); } - var message = "function raised exception " + - (err.toSource ? err.toSource() : err.stack); + var message = "function raised exception " + err.toSource(); if (doc) message += " with doc._id " + doc._id; log(message); }; diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl index 0aa85943f..0dedeba4d 100644 --- a/src/chttpd/src/chttpd_misc.erl +++ b/src/chttpd/src/chttpd_misc.erl @@ -68,7 +68,7 @@ handle_welcome_req(Req, _) -> send_method_not_allowed(Req, "GET,HEAD"). get_features() -> - case clouseau_rpc:connected() of + case dreyfus:available() of true -> [search | config:features()]; false -> diff --git a/src/couch/priv/couch_js/86/main.cpp b/src/couch/priv/couch_js/86/main.cpp index 06ff22428..3cb4b82c4 100644 --- a/src/couch/priv/couch_js/86/main.cpp +++ b/src/couch/priv/couch_js/86/main.cpp @@ -269,6 +269,8 @@ int runWithContext(JSContext* cx, couch_args* args) { JS_SetSecurityCallbacks(cx, &security_callbacks); JS::RealmOptions options; + // we need this in the query server error handling + options.creationOptions().setToSourceEnabled(enableToSource); JS::RootedObject global(cx, JS_NewGlobalObject(cx, &global_class, nullptr, JS::FireOnNewGlobalHook, options)); if (!global) diff --git a/src/couch/src/couch_bt_engine.erl b/src/couch/src/couch_bt_engine.erl index ca0828b6a..486ed7cb0 100644 --- a/src/couch/src/couch_bt_engine.erl +++ b/src/couch/src/couch_bt_engine.erl @@ -144,7 +144,7 @@ delete_compaction_files(RootDir, FilePath, DelOpts) -> is_compacting(DbName) -> lists:any( fun(Ext) -> - filelib:is_regular(DbName ++ Ext) + filelib:is_regular(?b2l(DbName) ++ Ext) end, [".compact", ".compact.data", ".compact.meta"] ). diff --git a/src/dreyfus/src/dreyfus.erl b/src/dreyfus/src/dreyfus.erl new file mode 100644 index 000000000..0fed3e60e --- /dev/null +++ b/src/dreyfus/src/dreyfus.erl @@ -0,0 +1,31 @@ +% Licensed under the Apache License, Version 2.0 (the "License"); you may not +% use this file except in compliance with the License. You may obtain a copy of +% the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +% License for the specific language governing permissions and limitations under +% the License. + +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- + +-module(dreyfus). + +-export([available/0]). + +available() -> + case application:get_env(dreyfus, available) of + {ok, Val} -> + Val; + undefined -> + case clouseau_rpc:connected() of + true -> + ok = application:set_env(dreyfus, available, true), + true; + false -> + false + end + end. diff --git a/src/jwtf/src/jwtf.erl b/src/jwtf/src/jwtf.erl index 1dedb36f1..2bb005bcb 100644 --- a/src/jwtf/src/jwtf.erl +++ b/src/jwtf/src/jwtf.erl @@ -310,8 +310,8 @@ decode_b64url_json(B64UrlEncoded) -> jiffy:decode(JsonEncoded) end catch - error:Error -> - throw({bad_request, Error}) + _:_ -> + throw({bad_request, <<"Malformed token">>}) end. props({Props}) -> diff --git a/src/jwtf/test/jwtf_tests.erl b/src/jwtf/test/jwtf_tests.erl index f4685a54e..e36ecbd23 100644 --- a/src/jwtf/test/jwtf_tests.erl +++ b/src/jwtf/test/jwtf_tests.erl @@ -39,28 +39,28 @@ jwt_io_pubkey() -> b64_badarg_test() -> Encoded = <<"0.0.0">>, ?assertEqual( - {error, {bad_request, badarg}}, + {error, {bad_request, <<"Malformed token">>}}, jwtf:decode(Encoded, [], nil) ). b64_bad_block_test() -> Encoded = <<" aGVsbG8. aGVsbG8. aGVsbG8">>, ?assertEqual( - {error, {bad_request, {bad_block, 0}}}, + {error, {bad_request, <<"Malformed token">>}}, jwtf:decode(Encoded, [], nil) ). invalid_json_test() -> Encoded = <<"fQ.fQ.fQ">>, ?assertEqual( - {error, {bad_request, {1, invalid_json}}}, + {error, {bad_request, <<"Malformed token">>}}, jwtf:decode(Encoded, [], nil) ). truncated_json_test() -> Encoded = <<"ew.ew.ew">>, ?assertEqual( - {error, {bad_request, {2, truncated_json}}}, + {error, {bad_request, <<"Malformed token">>}}, jwtf:decode(Encoded, [], nil) ). diff --git a/src/mango/src/mango_idx.erl b/src/mango/src/mango_idx.erl index a2daa8b9e..a20d730a2 100644 --- a/src/mango/src/mango_idx.erl +++ b/src/mango/src/mango_idx.erl @@ -175,7 +175,7 @@ from_ddoc(Db, {Props}) -> _ -> ?MANGO_ERROR(invalid_query_ddoc_language) end, IdxMods = - case clouseau_rpc:connected() of + case dreyfus:available() of true -> [mango_idx_view, mango_idx_text]; false -> @@ -250,7 +250,7 @@ cursor_mod(#idx{type = <<"json">>}) -> cursor_mod(#idx{def = all_docs, type = <<"special">>}) -> mango_cursor_special; cursor_mod(#idx{type = <<"text">>}) -> - case clouseau_rpc:connected() of + case dreyfus:available() of true -> mango_cursor_text; false -> @@ -262,7 +262,7 @@ idx_mod(#idx{type = <<"json">>}) -> idx_mod(#idx{type = <<"special">>}) -> mango_idx_special; idx_mod(#idx{type = <<"text">>}) -> - case clouseau_rpc:connected() of + case dreyfus:available() of true -> mango_idx_text; false -> @@ -289,7 +289,7 @@ get_idx_type(Opts) -> <<"json">> -> <<"json">>; <<"text">> -> - case clouseau_rpc:connected() of + case dreyfus:available() of true -> <<"text">>; false -> diff --git a/src/mango/src/mango_native_proc.erl b/src/mango/src/mango_native_proc.erl index 48c78c4c4..d3d200517 100644 --- a/src/mango/src/mango_native_proc.erl +++ b/src/mango/src/mango_native_proc.erl @@ -309,7 +309,7 @@ make_text_field_name([P | Rest], Type) -> validate_index_info(IndexInfo) -> IdxTypes = - case clouseau_rpc:connected() of + case dreyfus:available() of true -> [mango_idx_view, mango_idx_text]; false -> |