Cannot insert link at index 7 of array at path { table: "CompanyLocation", fullPath: "units" }, array has 6 elements and backfilling nulls in array of links are not supported


When I try to add a new item to the array inside MongoDB Realm, I get the following error:

  "To resolve this issue please update or replace the document in MongoDB to make sure it abides by the schema.",
  "Change Event Type: update",
  "Namespace: app.CompanyLocation",
  "Partition: dag1f7g7102aecdd3e9467711e",
  "Document ID: ObjectID(\"61f7f74a2aecdd3e9467711f\")",
  "Detailed Error: cannot insert link at index 7 of array at path { table: \"CompanyLocation\", fullPath: \"units\" }, array has 6 elements and backfilling nulls in array of links are not supported",
  "Number of Unsyncable Documents: 1"

I can’t understand what this error message tells me, can someone help explain it?

The code causing it:

 const newUnits = result.Shipment.Units[0] => u._attributes.UID +  u._attributes.PSN).flat();
  // Lägg till den som inventory på platsen."mongodb-atlas")
      _id: new BSON.ObjectId(place), 
      _partition: partition}, 
        $push: {
          units: {
            $each: newUnits

Thanks in advance!

Hi, I have actually been looking into this. At first glance it looks like it is works as designed from a different example I was looking at but this seems like it may be a bit different. I see that you have console.log() statements in that function, could you by chance send the contents of newUnits? If the information is sensitive, the main thing I am curious about is if there are nulls at the start of that list?

1 Like

Hello, thanks for a quick reply!

The array does not contain any null values. Anyway, here is the output of the console logs:



Here is an image of the full log history.

(nothing here is sensitive, it’s a test enviroment with mock data) :slight_smile:


1 Like

Quick update: I have actually figured out the issue (thanks to your reproduction) and it seems that it has to do with a change in how MongoDB reports changes in the newest version 5.0. Hoping to fix it up soon and will try to deploy it (likely sometime this next week)


Thanks & well done!

I am looking forward to the update :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.