Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-60623

[JS EVALUATOR] JS UDF function not properly try catching

    XMLWordPrintable

Details

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

      }

      Attachments

        1. image_1.png
          image_1.png
          429 kB
        2. image_2.png
          image_2.png
          354 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ajay.bhullar Ajay Bhullar
            ajay.bhullar Ajay Bhullar
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty