Seeing the error "Cannot require both kResult and MakeResultInfo" when attempting to run queries with a second project stage referencing a newly created field in a stage ($project/$addFields). Related to ticket SERVER-81466 that changes project generation.
Examples of queries that failed with this error (v7.2.0-rc1):
Note: Running on v6.0.11 works as expected with no error.
db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$newfield1" } }) db.atlascoll.aggregate({ "$addFields": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$newfield1" } })
Examples of queries that completed successfully:
db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$match": { "newfield1.a": 2 } }) - running a single $project followed by match db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$$ROOT" } }) - running two projects with the second one also referencing $$ROOT db.atlascoll.aggregate({ "$project": { "newfield1": "$$NOW" } }, { "$project": { "newfield2": "$newfield1" } }) - running the same query but using the system var $$NOW instead db.atlascoll.aggregate({ "$addFields": { "newfield1": "$$ROOT" } }, { "$addFields": { "newfield2": "$newfield1" } }) - using addFields instead of project
Some additional info in the slack thread here.