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

[UDF] Provide more granular error information for N1QL in Javascript UDF

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 7.1.0
    • 7.1.0
    • query
    • 7.1.0-1858
    • Untriaged
    • 1
    • Unknown

    Description

      With following UDF:

       function sp_insert(num) {
        try {
          var insert = num;
          var insert_statement = N1QL('INSERT INTO default (KEY, VALUE) VALUES ("k004", {"num_col1": $num })', {'num':num});
          return "Succeeded to insert " + insert;
        } catch (error) {
          return "Failed: " + error;
        }
      }
      

      N1QL error caught as part of JS udf are simple string e.g.

      DML Error, possible causes include concurrent modification. Failed to perform INSERT on key k004 - cause: Key k004 - cause: unable to complete action after 1 attempts: key exists" 

      We should provide more granular information in the error object like in cbq:

       [
        {
          "cause": {
            "caller": "couchbase:1944",
            "code": 5000,
            "icause": "unable to complete action after 1 attempts: key exists",
            "key": "Internal Error",
            "message": "Key k004"
          },
          "code": 12009,
          "msg": "DML Error, possible causes include concurrent modification. Failed to perform INSERT on key k004 - cause: Key k004 - cause: unable to complete action after 1 attempts: key exists"
        }
      ]

      Other vendors have this functionality, for example err contains:

      err.code
      err.state
      err.message
      err.stackTraceTxt

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            pierre.regazzoni Pierre Regazzoni
            pierre.regazzoni Pierre Regazzoni
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                PagerDuty