Details
-
Bug
-
Resolution: Fixed
-
Critical
-
7.6.0
-
7.6.0-2080
-
Untriaged
-
0
-
Yes
Description
I have a pretty simplistic case here
I create this JS function
curl -s -k -X POST http://172.23.216.252:8093/evaluator/v1/libraries/n1ql -u Administrator:password -H 'content-type: application/json' -d 'function error_handling() { try { var query1 = INSERT INTO default (KEY, VALUE) VALUES ("k004", {"col1": 10 }); var query2 = INSERT INTO default (KEY, VALUE) VALUES ("k004", {"col1": 10 }); return "Success!"; } catch(error) { n1ql_error = JSON.parse(error.message); return { "caller": n1ql_error.caller, "code": n1ql_error.code, "reason": n1ql_error.cause, "icode": n1ql_error.icause, "key": n1ql_error.key, "message": n1ql_error.message, "retry": n1ql_error.retry, "stack": error.stack }; } }'
|
As you can see this function runs 2 queries that insert to the same key, hence we should expect an error and for it to be caught, however when we run the JS UDF it is returning success, implying that the double insert didn't fail
CREATE OR REPLACE FUNCTION error_handling() LANGUAGE JAVASCRIPT AS "error_handling" AT "n1ql"
EXECUTE FUNCTION error_handling()
{'requestID': '7ed0aa48-4953-40a3-88da-f035df18df5a', 'signature': None, 'results': ['Success!'], 'status': 'success', 'metrics':
{'elapsedTime': '37.806707ms', 'executionTime': '37.683835ms', 'resultCount': 1, 'resultSize': 10, 'serviceLoad': 1}}