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
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.0
    • 3.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

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

        Activity

          eunice.huang Eunice Huang (Inactive) added a comment - - edited

          either of this one or CBL-858 logic is valid, but not both.

          eunice.huang Eunice Huang (Inactive) added a comment - - edited either of this one or CBL-858 logic is valid, but not both.
          jimb Jim Borden added a comment -

          By any chance was 2.6.4.2 a debug build?  This logic is checked and an exception is thrown for a debug build but not release build (maybe for performance reasons?).  This behavior has never changed in the entire 2.x timeframe. 

          jimb Jim Borden added a comment - By any chance was 2.6.4.2 a debug build?  This logic is checked and an exception is thrown for a debug build but not release build (maybe for performance reasons?).  This behavior has never changed in the entire 2.x timeframe. 
          jimb Jim Borden added a comment -

          According to Priya Rajagopal we are not going to fix this until 3.0 because it will break compatibility.  However we are going to discourage this behavior so the test fest app should continue to not use these keys. 

          jimb Jim Borden added a comment - According to Priya Rajagopal we are not going to fix this until 3.0 because it will break compatibility.  However we are going to discourage this behavior so the test fest app should continue to not use these keys. 
          priya.rajagopal Priya Rajagopal added a comment - FYI : Filed https://issues.couchbase.com/browse/DOC-6759

          Build couchbase-lite-core-3.0.0-9 contains couchbase-lite-core commit 6682394 with commit message:
          CBL-862: Reject invalid top level keys (#1076)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-core-3.0.0-9 contains couchbase-lite-core commit 6682394 with commit message: CBL-862 : Reject invalid top level keys (#1076)

          Build couchbase-lite-cblite-3.0.0-11 contains couchbase-lite-core commit 6682394 with commit message:
          CBL-862: Reject invalid top level keys (#1076)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-cblite-3.0.0-11 contains couchbase-lite-core commit 6682394 with commit message: CBL-862 : Reject invalid top level keys (#1076)

          Build couchbase-lite-log-3.0.0-12 contains couchbase-lite-core commit 6682394 with commit message:
          CBL-862: Reject invalid top level keys (#1076)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-log-3.0.0-12 contains couchbase-lite-core commit 6682394 with commit message: CBL-862 : Reject invalid top level keys (#1076)

          Build couchbase-lite-net-3.0.0-9 contains couchbase-lite-core commit 6682394 with commit message:
          CBL-862: Reject invalid top level keys (#1076)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-net-3.0.0-9 contains couchbase-lite-core commit 6682394 with commit message: CBL-862 : Reject invalid top level keys (#1076)

          Build couchbase-lite-net-3.0.0-9 contains couchbase-lite-net commit 4c2d539 with commit message:
          Update LiteCore to Commit: 6682394694e1aa6b355461727e5d534200abf53e [6682394] (CBL-862: Reject invalid top level keys)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-net-3.0.0-9 contains couchbase-lite-net commit 4c2d539 with commit message: Update LiteCore to Commit: 6682394694e1aa6b355461727e5d534200abf53e [6682394] ( CBL-862 : Reject invalid top level keys)

          Build couchbase-lite-android-3.0.0-17 contains couchbase-lite-core commit 6682394 with commit message:
          CBL-862: Reject invalid top level keys (#1076)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-android-3.0.0-17 contains couchbase-lite-core commit 6682394 with commit message: CBL-862 : Reject invalid top level keys (#1076)

          Build couchbase-lite-java-3.0.0-17 contains couchbase-lite-core commit 6682394 with commit message:
          CBL-862: Reject invalid top level keys (#1076)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-java-3.0.0-17 contains couchbase-lite-core commit 6682394 with commit message: CBL-862 : Reject invalid top level keys (#1076)

          Build couchbase-lite-ios-3.0.0-31 contains couchbase-lite-core commit 6682394 with commit message:
          CBL-862: Reject invalid top level keys (#1076)

          build-team Couchbase Build Team added a comment - Build couchbase-lite-ios-3.0.0-31 contains couchbase-lite-core commit 6682394 with commit message: CBL-862 : Reject invalid top level keys (#1076)

          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:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty