I have a query that has been unchanged for years that has just started failing with the message:
$arrayElemAt’s first argument must be an array, but is int
I can reproduce it at the Mongo sh, e.g.
db.transaction.find({ $expr: { “$eq” : [ { “$arrayElemAt” : [ “$TransactionStatus.StatusType”, -1 ] }, 1 ] } })
I can see several groups (paging with “it”), but eventually it errors:
Error: command failed: {
“ok” : 0,
“errmsg” : “Executor error during getMore :: caused by :: $arrayElemAt’s first argument must be an array, but is int”,
“code” : 28689,
“codeName” : “Location28689”,
“$clusterTime” : {
“clusterTime” : Timestamp(1738928181, 1),
“signature” : {
“hash” : BinData(0,“LfnwaDc1kPPHyBoQxwK4VWqGA+I=”),
“keyId” : NumberLong(“7416883275756470273”)
}
},
“operationTime” : Timestamp(1738928181, 1)
} : getMore command failed: {
“ok” : 0,
“errmsg” : “Executor error during getMore :: caused by :: $arrayElemAt’s first argument must be an array, but is int”,
“code” : 28689,
“codeName” : “Location28689”,
“$clusterTime” : {
“clusterTime” : Timestamp(1738928181, 1),
“signature” : {
“hash” : BinData(0,“LfnwaDc1kPPHyBoQxwK4VWqGA+I=”),
“keyId” : NumberLong(“7416883275756470273”)
}
},
“operationTime” : Timestamp(1738928181, 1)
}
How can I find the record that is causing the error? There are 80,000 matches in the DB.