question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

failedToParse: The 'cursor' option is required, except for aggregate with the explain argument

See original GitHub issue
$ mongo
MongoDB shell version v3.6.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.0
Mongo-Hacker 0.0.14

> db.coll.insert({string: 'hello world1 world2'} )

> db.coll.aggregate([{ $project: { location: { $indexOfBytes: ["$string", "world"] } } }])
printStackTrace@src/mongo/shell/utils.js:74:15
DBCollection.prototype.aggregate@/Users/gianfranco/.mongorc.js:98:13
@(shell):1:1

2017-12-17T18:49:20.838+0200 E QUERY    [thread1] uncaught exception: aggregate failed: {
  "ok": 0,
  "errmsg": "The 'cursor' option is required, except for aggregate with the explain argument",
  "code": 9,
  "codeName": "FailedToParse"
}

Issue also with aggregate() function without the array.

> db.coll.aggregate().project({ location: { $indexOfBytes: ["$string", "world"] } })
printStackTrace@src/mongo/shell/utils.js:74:15
Aggregation.prototype.execute@/Users/gianfranco/.mongorc.js:152:9
Aggregation.prototype.shellPrint@/Users/gianfranco/.mongorc.js:170:9
shellPrintHelper@src/mongo/shell/utils.js:539:1
@(shell2):1:1

2017-12-17T18:56:54.026+0200 E QUERY    [thread1] uncaught exception: aggregation failed: {
  "ok": 0,
  "errmsg": "The 'cursor' option is required, except for aggregate with the explain argument",
  "code": 9,
  "codeName": "FailedToParse"
}
$ mongo --norc

> db.coll.aggregate([{ $project: { location: { $indexOfBytes: ["$string", "world"] } } }])
{ "_id" : ObjectId("5a36a07f36f314ee708bdf8b"), "location" : 6 }

same issue with mongo shell 3.4.3 btw

Looks like the issue is also(?) related to the server version

  • Server 3.4.3 with mongo shell 3.4.3 + mongo hacker ✅
  • Server 3.4.3 with mongo shell 3.6.0 + mongo hacker ✅
  • Server 3.6.0 with mongo shell 3.6.0 or 3.4.3 + mongo hacker ❌

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
mov-qcommented, Feb 9, 2018

any fix for this issue? experiencing the same problem with latest stable 3.6.x mongodb and latest mongo-hacker

6reactions
wolphcommented, Oct 27, 2018

I’ve created a pull request 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring data mongodb - The 'cursor' option is required
MongoDB changed in 3.6 how the aggregation command works. Aggregations require now a cursor. We adapted Spring Data MongoDB 2.1 but not ...
Read more >
The 'cursor' option is required, except for aggregate ... - GitHub
Hi After running a mongo and mirrogate dockers (from readme files) and trying to save a dashboard I got an error :com.mongodb.
Read more >
Aggregation examples don't work due to missing cursor option
"errmsg" : "The 'cursor' option is required, except for aggregate with the explain argument",. "code" : 9,. "codeName" : "FailedToParse".
Read more >
Lab 4.2 Aggregation Performance - M201 - MongoDB
... "errmsg": "The 'cursor' option is required, except for aggregate with the explain argument", "code": 9, "codeName": "FailedToParse" }.
Read more >
Node.js – Mongodb error : The 'cursor' option is required ...
How can I fix them? The error message: { MongoError: The 'cursor' option is required, except for aggregation explain at Function.MongoError.create (/data/deploy ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found