Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-862

CBL 2.7 and later doesn't catch Illegal top-level key like "_id"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.0
    • 2.7.0
    • LiteCore
    • Security Level: Public
    • None
    • Jim 32
    • 3

    Description

      mobile-testkit framework has a generic function to create bulk documents, this function add documents whose data contains a key/value pair like below:

      _id = doc_id_name

      the key _id is considered as an illegal top-level key, 2.6.4.2-1 Android build capture this issue, however, not 2.7 or later CBL fail on this validation during the weekly test run.

      Repro Steps:

      1. use 2.7. or 2.8 CBL Android build
      2. prepare a document like this:
      MutableDocument document = new MutableDocument(id, data);
      in this case, set id = cbl_1
      and data = {channels=[ABC], dict_with_list=

      {list=[true, false]}

      , dict=

      {name=zFakpGdcYp}

      , list=[2115284486470778685, 1745721136811925734], date_time_added=2020-04-15 11:55:22.303358, list_of_dicts=[

      {friend_one=QYLGYazGqd}

      ,

      {friend_two=VQYPpYGBJe}

      ], _id=cbl_1, updates=0}
      3. call database.save(document)

      Expected Result:
      save function throws exception:
      CouchbaseLiteException

      {CouchbaseLite,5,'Illegal top-level key `_id` in document'}

      at com.couchbase.lite.CBLStatus.convertException(CBLStatus.java:81)
      at com.couchbase.lite.CBLStatus.convertException(CBLStatus.java:32)
      at com.couchbase.lite.AbstractDatabase.saveInTransaction(AbstractDatabase.java:1460)
      at com.couchbase.lite.AbstractDatabase.saveInternal(AbstractDatabase.java:1366)
      at com.couchbase.lite.AbstractDatabase.save(AbstractDatabase.java:399)
      at com.couchbase.lite.Database.save(Database.java:31)
      .......

      Actual Result:
      document is saved successfully, no validation check placed/failed

      Attachments

        Activity

          People

            eunice.huang Eunice Huang (Inactive)
            eunice.huang Eunice Huang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty