Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Mongo aggregate command doesn't parse BSON pipelines properly (variation of #6582) #16887

Open
1 task done
nzidol opened this issue Sep 20, 2022 · 2 comments
Open
1 task done
Labels
Backend This marks the issue or pull request to reference server code Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Integrations Product Issues related to a specific integration Mongo Issues related to Mongo DB plugin Production Query & JS Pod Issues related to the query & JS Pod

Comments

@nzidol
Copy link

nzidol commented Sep 20, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Description

Aggregate command parses the user input for pipelines and the example from #6582 now works correct. However when mixing the pipeline with some JavaScript parsing errors occur though the evaluated value shown is a correct pipeline.
image
image

The key issue seems to be that the ':' that separates the key/value pair cannot be inside the {{JavaScript}} element although evaluated value is exactly the same.
image
image

Steps To Reproduce

  1. Create a Mongo query.
  2. Set the command type to Aggregate and choose any collection
  3. In the array of pipelines use a command along the following lines :
    [ {$sort :{ _id : 1 }}, { $project: { age : 1}}, {$count: "userCount"} ]
  4. Run the query. It shows a document count.
  5. Add a table to the page and update the query:
    [ { $sort :{ {{ Table1.sortOrder.column != "" ? '_id : 1' : '_id : -1 ' }} } }, { $project: { age : 1}}, { $count: "userCount"} ]
  6. Inspect the evaluated value, it shows the identical code from step 3
  7. Run the query, a parsing error is reported
  8. Update query to:
    [ { $sort :{ _id : {{ Table1.sortOrder.order == "desc" ? '-1' : '1' }} } }, { $project: { age : 1}}, { $count: "userCount"} ]
  9. Inspect the evaluated value, it shows the identical code from step 3
  10. Run the query, it shows a document count.
  11. Update query to: (note the ':' )
    [ { $sort :{ {{ Table1.sortOrder.column != "" ? '_id' : '_id' }} : {{ Table1.sortOrder.order == "desc" ? '-1' : '1' }} } }, { $project: { age : 1}}, { $count: "userCount"} ]
  12. Inspect the evaluated value, it shows the identical code from step 3
  13. Run the query, it shows a document count.
  14. Update query to: (note the ':' )
    [ { $sort :{ {{ Table1.sortOrder.column != "" ? '_id:' : '_id:' }} {{ Table1.sortOrder.order == "desc" ? '-1' : '1' }} } }, { $project: { age : 1}}, { $count: "userCount"} ]
  15. Inspect the evaluated value, it shows the identical code from step 3
  16. Run the query, it shows a parsing error.

Public Sample App

No response

Version

Self Hosted 1.8.0

@nzidol nzidol added Bug Something isn't working Needs Triaging Needs attention from maintainers to triage labels Sep 20, 2022
@pranavkanade pranavkanade added the Mongo Issues related to Mongo DB plugin label Sep 20, 2022
@github-actions github-actions bot added the Integrations Product Issues related to a specific integration label Sep 20, 2022
@rohan-arthur
Copy link
Contributor

@nzidol thanks for reporting this bug and appreciate the detailed description. We will look into this.

@Nikhil-Nandagopal Nikhil-Nandagopal added the High This issue blocks a user from building or impacts a lot of users label Sep 26, 2022
@github-actions github-actions bot added the Query & JS Pod Issues related to the query & JS Pod label Sep 26, 2022
@sribalajig sribalajig removed the Needs Triaging Needs attention from maintainers to triage label Jan 19, 2023
@sribalajig
Copy link

@rohan-arthur

@sumitsum sumitsum added the Backend This marks the issue or pull request to reference server code label Jun 30, 2023
@Nikhil-Nandagopal Nikhil-Nandagopal added Enhancement New feature or request and removed Enhancement New feature or request labels Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend This marks the issue or pull request to reference server code Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Integrations Product Issues related to a specific integration Mongo Issues related to Mongo DB plugin Production Query & JS Pod Issues related to the query & JS Pod
Projects
None yet
Development

No branches or pull requests

7 participants