[SERVER-27730] ReferenceError: singleBatchType is not defined when attempting to retrieve a document Created: 18/Jan/17  Updated: 10/Jul/17  Resolved: 30/Jan/17

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: James Ridgway Assignee: Mark Agarunov
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Overview
We have noticed that we are unable to retrieve a document successfully via the mongo shell or by using the java driver.

mongo
An attempt to retrieve the mongo document via mongoshell results in the following:

MongoDB shell version: 3.2.10
connecting to: mongodb.example.net/testdb
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
floow:PRIMARY> db.users.find({"_id":ObjectId("57fbaa66f48ba92249b75916")})
ReferenceError: singleBatchType is not defined

mongoexport
In an attempt to look at the document and the state of the document, we attempted to export it via mongoexport, this resulted in the following:

mongoexport -h mongodb.example.net -d testdb -c users | grep "57fbaa66f48ba92249b75916"
2017-01-18T07:55:54.329+0000	connected to: mongodb.example.net
{"_id":{"$oid":"57fbaa66f48ba92249b75916"},"ok":{"$undefined":true},"nInserted":1.0,"nUpserted":0.0,"nMatched":0.0,"nModified":0.0,"nRemoved":0.0,"getUpsertedId":{"$code":"function () {\n      if (bulkResult.upserted.length == 0) {\n        return null;\n      }\n\n      return bulkResult.upserted[bulkResult.upserted.length - 1];\n    }"},"getRawResponse":{"$code":"function () {\n      return bulkResult;\n    }"},"getWriteError":{"$code":"function () {\n      if (bulkResult.writeErrors.length == 0) {\n        return null;\n      } else {\n        return bulkResult.writeErrors[bulkResult.writeErrors.length - 1];\n      }\n    }"},"hasWriteError":{"$code":"function () {\n      return this.getWriteError() != null;\n    }"},"getWriteConcernError":{"$code":"function () {\n      if (bulkResult.writeConcernErrors.length == 0) {\n        return null;\n      } else {\n        return bulkResult.writeConcernErrors[0];\n      }\n    }"},"hasWriteConcernError":{"$code":"function () {\n      return this.getWriteConcernError() != null;\n    }"},"tojson":{"$code":"function (indent, nolint) {\n      var result = {}\n\n      if(singleBatchType == INSERT) {\n        result.nInserted = this.nInserted;\n      }\n\n      if(singleBatchType == UPDATE) {\n        result.nMatched = this.nMatched;\n        result.nUpserted = this.nUpserted;\n\n        if(this.nModified != undefined)\n            result.nModified = this.nModified;\n\n        if(Array.isArray(bulkResult.upserted)\n            \u0026\u0026 bulkResult.upserted.length == 1) {\n          result._id = bulkResult.upserted[0]._id;\n        }\n      }\n\n      if(singleBatchType == REMOVE) {\n        result.nRemoved = bulkResult.nRemoved;\n      }\n\n      if(this.getWriteError() != null) {\n        result.writeError = {};\n        result.writeError.code = this.getWriteError().code;\n        result.writeError.errmsg = this.getWriteError().errmsg;\n      }\n\n      if(this.getWriteConcernError() != null) {\n        result.writeConcernError = this.getWriteConcernError();\n      }\n\n      return tojson(result, indent, nolint);\n    }"},"toString":{"$code":"function () {\n      // Suppress all output for the write concern w:0, since the client doesn't care.\n      if(writeConcern \u0026\u0026 writeConcern.w == 0) {\n        return \"WriteResult(\" + tojson({}) + \")\";;\n      }\n      return \"WriteResult(\" + this.tojson() + \")\";\n    }"},"shellPrint":{"$code":"function () {\n      return this.toString();\n    }"}}



 Comments   
Comment by James Ridgway [ 21/Jan/17 ]

Hi Mark,

Thank you for getting back to me so quickly.

So in this given instance the record will have been inserted using an insert command from mongo shell. I don't have the original query, nor is it likely that we still have the mongos logs.

I suspect that this has been caused by human error. On the basis that we cannot provide further details I am happy for this issue to be closed.

Thanks

Comment by Mark Agarunov [ 18/Jan/17 ]

Hi jamesridgway,

Thank you for the report. Looking over the output you've provided, it seems that some javascript may have been inserted into the database instead of your document. In order to better assess this issue, I'd like to ask a couple questions to clarify.

  • How was this document initially inserted into the collection? Please provide the exact query used, if possible.
  • What is the expected content of the document?

Additionally, if you are able to, please send the mongod logs from when this document was inserted.

Thanks,
Mark

Generated at Thu Feb 08 04:16:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.