$addToSet inserting an empty object in server code but not in console

I have a meteor method that makes the following call:

Groups.update("thesamegroupId", {
    $addToSet: { 
        contacts: { 
            name: 'somestring', 
            email: "anotherstring", 
            phone: "anotherstring", 
            _id: "anotherstring" 
        }
    }
});

And will insert an empty object into the contacts array.
Using an identical query in the meteor mongo console however produces a different result.

db.groups.update("thesamegroupId", {
    $addToSet: { 
        contacts: { 
            name: 'somestring', 
            email: "anotherstring", 
            phone: "anotherstring", 
            _id: "anotherstring" 
        }
    }
});

Will correctly insert the described object onto the contacts array.

I’ve tried for two hours to google foo this, and have come up with nothing. Any help would be appreciated, do not hesitate to ask for more info if needed.

Are you using Simple Schema? If so are you sure your contact object is passing your schema’s validation? Simple Schema handles $addToSet operators (along with many others), so it could be cleaning (removing) your properties.

You are absolutely right I feel so stupid. I expected simple schema not to clean undeclared fields in an array of objects, I should’ve read the docs more carefully.

For anyone who sees this in the future, you must declare fields within objects within an array like so

collection.arrayField.$.objectProperty: {
    type: <type>
}

Thanks!