You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running doctrine:mongodb:schema:update with mongo 5 throws a weird error BSON field 'collMod.validator' is the wrong type 'array', expected type 'object' but on Mongo 4.4 works
Detailed version
I have a problem that I'm facing for some days already and have no idea how to fix it, maybe sharing here someone can help me.
When running ./bin/console doctrine:mongodb:schema:update I got a weird Mongo 5 error that I have no idea about it, the error is:
BSON field 'collMod.validator' is the wrong type 'array', expected type 'object'
When doing elimination I excluded document by document in my classes definitions and end-up in the Category class below, I removed the whole document definition leaving only the ID, also tried excluding this class, copying a working one to the same name or different but the same error happens. Tried downgrading many packages but still no success.
When schema:drop the schema:create it works, indexes are there. But the schema:update just crashes.
My last attempt was to downgrade to mongo 4.4, and to my surprise, it works, not sure what happens in version 5 but there is some incompatibility that I can not debug or trace more details.
Just want to share here, maybe someone else faces the same error or has the real solution for the problem.
/var/www/html # ./bin/console doctrine:mongodb:mapping:info
Found 12 documents mapped in document manager default:
[OK] Project\Api\Category\Document\Category
[OK] Project\Api\Chat\Document\Chat
[OK] Project\Api\Chat\Document\Embedded\Message
[OK] Project\Api\Favorite\Document\Favorite
[OK] Project\Api\Item\Document\Embedded\Contact
[OK] Project\Api\Item\Document\Embedded\Price
[OK] Project\Api\Item\Document\Embedded\Statistics
[OK] Project\Api\Item\Document\Item
[OK] Project\Api\Shared\Document\Location
[OK] Project\Api\Tracking\Document\Tracking
[OK] Project\Api\User\Document\Embedded\Flag
[OK] Project\Api\User\Document\User
/var/www/html # ./bin/console doctrine:mongodb:schema:create
Created collections for all classes
Created indexes for all classes
/var/www/html # ./bin/console doctrine:mongodb:schema:update
Updated indexes for all classes
BSON field 'collMod.validator' is the wrong type 'array', expected type 'object'
I faced the same error today and it is the $validator variable by default set as an array in ODM/MongoDB/SchemaManager.php in the updateDocumentValidator() method who triggers the error.
If you edit by $validator = (object) []; it works correctly but it is just a quick workaround...
The first step forward would be to add MongoDB 5.0 to the test matrix as we haven't gotten to it yet. Hopefully some of our tests will break :) @douglasjam@GuiReco anybody up for a PR?
TL;DR
Running
doctrine:mongodb:schema:update
with mongo 5 throws a weird errorBSON field 'collMod.validator' is the wrong type 'array', expected type 'object'
but on Mongo 4.4 worksDetailed version
I have a problem that I'm facing for some days already and have no idea how to fix it, maybe sharing here someone can help me.
When running
./bin/console doctrine:mongodb:schema:update
I got a weird Mongo 5 error that I have no idea about it, the error is:BSON field 'collMod.validator' is the wrong type 'array', expected type 'object'
When doing elimination I excluded document by document in my classes definitions and end-up in the Category class below, I removed the whole document definition leaving only the ID, also tried excluding this class, copying a working one to the same name or different but the same error happens. Tried downgrading many packages but still no success.
When
schema:drop
theschema:create
it works, indexes are there. But theschema:update
just crashes.My last attempt was to downgrade to mongo 4.4, and to my surprise, it works, not sure what happens in version 5 but there is some incompatibility that I can not debug or trace more details.
Just want to share here, maybe someone else faces the same error or has the real solution for the problem.
Environment versions with the error:
mongodb/mongodb: "^1.10",
doctrine/mongodb-odm-bundle: "^4.4",
symfony/*: ^5.4
mongo: 5.0.1
ext-mongo: 1.11.1
All my console output + Logs
console log
mongo.log
The Document in which if I remove it works
doctrine_mongodb.yaml
The text was updated successfully, but these errors were encountered: