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

Warning mark not decorating Javascript on bad args

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 7.6.0
    • eventing
    • None
    • Untriaged
    • 0
    • Unknown

    Description

      I tried an AI generated Eventing function and it used couchbase.upsert() but the arguments were wrong  so it errored out on all docs in travel-sample.inventory.hotel when deployed.

      This is a defined function couchbase.upsert(meta.id, doc); with bad arguments and the marker is not placed, see image mb_shows_issus_exisiting_func_bad_args.jpg fully deployed.

      2024-01-25T07:39:27.571-08:00 [INFO] {"count":917,"exception":"\"TypeError: 1st argument should be bucket object\"","file":"couchbase.js","line":51,"since":"2024-01-25T07:38:22","srcLine":"var details = couchbase.bindingDetails(bucket, meta);","stack":"TypeError: 1st argument should be bucket object\n    at couchbase.upsert (couchbase.js:52:31)\n    at OnUpdate (no_warning_marker_in_js.js:7:19)"}

       

      Below is a non-defined function and the marker is fine, see image mb_okay_no_such_function.jpg fully deployed.

      2024-01-25T07:35:57.584-08:00 [INFO] {"exception":"\"ReferenceError: nosuchbuiltin is not defined\"","file":"no_warning_marker_in_js.js","line":8,"srcLine":"nosuchbuiltin(8);","stack":"ReferenceError: nosuchbuiltin is not defined\n    at OnUpdate (no_warning_marker_in_js.js:9:9)"}

       

      Here is the test function I used commented to be image mb_shows_issus_exisiting_func_bad_args.jpg i.e. it doesn't set the yellow warnign marker!

      function OnUpdate(doc, meta) {
          // Check if the document is from the hotel inventory
          if (meta.id.startsWith("hotel_")) {
              doc.ave_rating = 8;
              // BAD Will not place marker on next line due to BAD args
              couchbase.upsert(meta.id, doc);
              // OKAY
              // nosuchbuiltin(8);
              // OKAY
              // src_alias[meta.id] = doc;
          }
      }

       

      The function settings are shown in image mb_function_settings.jpg

      Attachments

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

        Activity

          People

            santosh.hegde Santosh Hegde
            jon.strabala Jon Strabala
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty