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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.2.6
    • Component/s: Index Maintenance
    • None
    • Server Triage
    • ALL
    • 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.

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

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

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

              Created:
              Updated:
              Resolved: