Unable to get collStats for oplog.rs in Mongo version 7 using the Java driver

Hi all, I have the following code:

try (MongoClient mongoClient = MongoClients.create(connectionString)) {
    MongoDatabase localDatabase = mongoClient.getDatabase("local");
    Document stats = localDatabase.runCommand(new Document("collStats", "oplog.rs"));
    MongoCollection<Document> oplogCollection = localDatabase.getCollection("oplog.rs");
}

I am able to get the collStats for the local.oplog.rs collection fine for Mongo versions < 7.0 using the same user. However, for 7.0+, I’m getting the following permission-related error:

(Unauthorized) not authorized on local to execute command { COLLSTATS: "oplog.rs", $db: "local", $clusterTime: { clusterTime: {1711045201 7}, signature: { hash: {0 [153 24 167 133 151 235 245 0 46 198 71 156 150 84 203 183 242 37 114 233]}, keyId: 7299222831366144000.000000 } }, lsid: { id: {4 [223 40 62 26 188 53 72 215 130 84 193 23 174 51 82 96]} } }' on server ac-urlustv-shard-00-01.bxzexuy.mongodb.net:27017. The full response is {"ok": 0, "errmsg": "(Unauthorized) not authorized on local to execute command { COLLSTATS: \"oplog.rs\", $db: \"local\", $clusterTime: { clusterTime: {1711045201 7}, signature: { hash: {0 [153 24 167 133 151 235 245 0 46 198 71 156 150 84 203 183 242 37 114 233]}, keyId: 7299222831366144000.000000 } }, lsid: { id: {4 [223 40 62 26 188 53 72 215 130 84 193 23 174 51 82 96]} } }", "code": 8000, "codeName": "AtlasError"}

My user has admin permissions and I ensured that it also has the read@local permission explicitly enabled. This same user is able to execute the above command for Mongo deployments with versions < 7.0.

The Mongo Java driver version I’m using is 4.7.0.