Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-48998

Getting "Unexpected error" instead of "Duplicate key error" while trying to insert or update duplicate value in Array(of objects) > Field

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Done
    • Affects Version/s: 4.2.6
    • Fix Version/s: None
    • Component/s: Index Maintenance
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide
      1. Create a document with array of objects, say "children", and those array element objects having a field, say "childId".
        Eg:

        {
         "children": [{
         "childId": "child1"
         }, {
         "childId": "child2"
         }]
        }
        

      2. Create an unique index on children>childId
      3. Create another document with same data, but different childId values.
        Eg:

        {
         "children": [{
         "childId": "child3"
         }, {
         "childId": "child4"
         }]
        }
        

      4. In Mongodb Atlas web, clone the document to create a new document with same details. You'll get an error: "Unexpected error"
      5. In Mongodb compass, object view ( {} ), try doing the same, will get issue most of the times, the screen goes blank!
      6. In Mongodb compass, list view, try doing the same, it works as expected most of the times.
      7. If cloning works, without any error, do the following: update the second document to add another object to "children" array with "childId": "child1" (to be a duplicate of childId of an element of first document). You'll get the error.
      Show
      Create a document with array of objects, say "children", and those array element objects having a field, say "childId". Eg: { "children": [{ "childId": "child1" }, { "childId": "child2" }] } Create an unique index on children>childId Create another document with same data, but different childId values. Eg: { "children": [{ "childId": "child3" }, { "childId": "child4" }] } In Mongodb Atlas web, clone the document to create a new document with same details. You'll get an error: "Unexpected error" In Mongodb compass, object view ( {} ), try doing the same, will get issue most of the times, the screen goes blank! In Mongodb compass, list view, try doing the same, it works as expected most of the times. If cloning works, without any error, do the following: update the second document to add another object to "children" array with "childId": "child1" (to be a duplicate of childId of an element of first document). You'll get the error.

      Description

      Getting "Unexpected error" instead of "Duplicate key error" while trying to insert or update duplicate value in Array(of objects) > Field

        Attachments

        1. Capture1.5-2.PNG
          Capture1.5-2.PNG
          28 kB
        2. Capture-2.PNG
          Capture-2.PNG
          11 kB
        3. Capture2-2.PNG
          Capture2-2.PNG
          20 kB
        4. Capture3-3.PNG
          Capture3-3.PNG
          9 kB
        5. Capture4-1.PNG
          Capture4-1.PNG
          16 kB
        6. Capture5-1.PNG
          Capture5-1.PNG
          17 kB
        7. Capture6-1.PNG
          Capture6-1.PNG
          14 kB
        8. Capture7.PNG
          Capture7.PNG
          14 kB
        9. Capture8.PNG
          Capture8.PNG
          13 kB
        10. Capture9.PNG
          Capture9.PNG
          21 kB

          Activity

            People

            Assignee:
            backlog-server-triage Backlog - Triage Team
            Reporter:
            arpanbag1996@gmail.com Arpan Bag
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: