[SERVER-56055] "indexOf is not a function" error for collection name "1000" in shell Created: 12/Apr/21  Updated: 20/Apr/21  Resolved: 20/Apr/21

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

Type: Bug Priority: Major - P3
Reporter: Andrew Marshall Assignee: Eric Sedor
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-445 Can't reference collection names begi... Closed
Operating System: ALL
Steps To Reproduce:

breaking-serverless-1-shard-00-01(mongos-4.9.0-rc0)[mongos] CORE> db.check.insertOne({})
{
  "acknowledged": true,
  "insertedId": ObjectId("6074aad76e02669be98128d8")
}
breaking-serverless-1-shard-00-01(mongos-4.9.0-rc0)[mongos] CORE> db.check.aggregate({$out: "10000"})
{
  "cursor": {
    "firstBatch": [ ],
    "id": NumberLong("0"),
    "ns": "CORE.check"
  },
  "ok": 1,
  "$clusterTime": {
    "clusterTime": Timestamp(1618258651, 15009),
    "signature": {
      "hash": BinData(0, "DmTvCASPK04UTi/hhR+6fpgIq/I="),
      "keyId": NumberLong("6948896105811673091")
    }
  },
  "operationTime": Timestamp(1618258651, 15009)
}
breaking-serverless-1-shard-00-01(mongos-4.9.0-rc0)[mongos] CORE> show collections
100000.000MB / 0.008MB
check → 0.000MB / 0.008MB
breaking-serverless-1-shard-00-01(mongos-4.9.0-rc0)[mongos] CORE> db["10000"].find()
TypeError: this._collection.getName(...).indexOf is not a function

Participants:

 Description   
  • You can use the $out operator to create collection with numeric names
  • Further operations on this collection will fail


 Comments   
Comment by Eric Sedor [ 16/Apr/21 ]

Hi andrew.marshall; this is indeed a shell matter, and this is similar to SERVER-445. This comment discusses using the documented shell workaround of getCollection()

Comment by Andrew Marshall [ 12/Apr/21 ]

Running the "runCommand" function worked
breaking-serverless-1-shard-00-01(mongos-4.9.0-rc0)[mongos] CORE> db.runCommand({find: "1000"})
{
"cursor":

{ "id": NumberLong("0"), "ns": "CORE.1000", "firstBatch": [ ] }

,
"ok": 1,
"$clusterTime": {
"clusterTime": Timestamp(1618258870, 7),
"signature":

{ "hash": BinData(0, "dYunMJvzOilGqpc+YdxQfOw4WbE="), "keyId": NumberLong("6948896105811673091") }

},
"operationTime": Timestamp(1618258870, 7)
}
So could just be a shell bug

Generated at Thu Feb 08 05:38:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.