[SERVER-77991] $$USER_ROLES not available within aggregation sub-pipeline Created: 12/Jun/23  Updated: 29/Oct/23  Resolved: 08/Sep/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0, 7.0.2, 7.1.0-rc3

Type: Bug Priority: Major - P3
Reporter: Will Buerger Assignee: Militsa Sotirova
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.1, v7.0
Sprint: QO 2023-09-04, QO 2023-09-18
Participants:

 Description   

The query 

db.coll.aggregate([{$lookup: {from: "other", let: {role: "$role"}, pipeline:[{$match:{$expr: {$eq:["$role", "$$USER_ROLES.role"]}}}], as: "out"}}])

fails with the error "PlanExecutor error during aggregation :: caused by :: error while multiplanner was selecting best plan :: caused by :: Builtin variable '$$USER_ROLES' is not available" (code 51144).

 

Given that the query 

db.other.aggregate([{$match: {$expr: {$eq: ["$role", "$$USER_ROLES.role"]}}}])

succeeds and behaves as anticipated, I suspect this is due to $$USER_ROLES not being set properly for a sub-pipeline.



 Comments   
Comment by Githook User [ 14/Sep/23 ]

Author:

{'name': 'Militsa Sotirova', 'email': 'militsa.sotirova@mongodb.com', 'username': 'militsasotirova'}

Message: SERVER-77991 Support USER_ROLES variable in subpipelines
Branch: v7.1
https://github.com/mongodb/mongo/commit/1873da68e9232a4cd032814a563925d36a534398

Comment by Githook User [ 14/Sep/23 ]

Author:

{'name': 'Militsa Sotirova', 'email': 'militsa.sotirova@mongodb.com', 'username': 'militsasotirova'}

Message: SERVER-77991 Support USER_ROLES variable in subpipelines
Branch: v7.0
https://github.com/mongodb/mongo/commit/68619a95c30d1b01bd5bf1c0828aa7e01327ae98

Comment by Githook User [ 08/Sep/23 ]

Author:

{'name': 'Militsa Sotirova', 'email': 'militsa.sotirova@mongodb.com', 'username': 'militsasotirova'}

Message: SERVER-77991 Support USER_ROLES variable in subpipelines
Branch: master
https://github.com/mongodb/mongo/commit/9321b44d1235e69bb85916adbfe5fb2019f07d5a

Comment by Ana Meza [ 13/Jun/23 ]

Passing this to you militsa.sotirova@mongodb.com since you did the work to introduce user roles

Generated at Thu Feb 08 06:37:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.