Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-1472

Invalid JSON parsed incorrectly as valid

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.2.2
    • 3.2.1
    • library
    • None
    • 1

    Description

      The analytics situational test I added that restarts the couchbase service fails consistently with an assertion in the lcb json library

      /home/***/jenkins/workspace/c-cpp/lcb/qe-situational-lcb/lib***/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp:2366: void Json::throwLogicError(const string&): Assertion `false' failed.

      http://sdk.jenkins.couchbase.com/view/Situational/job/c-cpp/job/lcb/job/qe-situational-lcb/866/console

      After investigating, the analytics service is returning a 503 error with a plaintext body of "503 Service Unavailable" at the moment the service is restarted (possible a separate issue).

      lcb_ANALYTICS_HANDLE_::invoke_row does not check the content type so tries to decode it as json. "503 Service Unavailable" should be invalid JSON

      jakerawsthorne@REML0715 libcouchbase % node
      Welcome to Node.js v14.10.0.
      Type ".help" for more information.
      > JSON.parse("503 Service Unavailable")
      Uncaught SyntaxError: Unexpected token S in JSON at position 4

      however lcb-jsoncpp parses it as the number 503. Failing test case: http://review.couchbase.org/c/libcouchbase/+/160062

      When invoke_row calls const Json::Value &errors = meta["errors"]; the assertion is hit because you can't index into a number

      Attachments

        Issue Links

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

          Activity

            People

              avsej Sergey Avseyev
              jake.rawsthorne#1 Jake Rawsthorne [X] (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty