Skip to content

Commit b369686

Browse files
committed
fix: throw error in BinMsg and remove if stmt in add_user
1 parent 74a137a commit b369686

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/cmap/commands.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ReadPreference } from '../read_preference';
22
import * as BSON from '../bson';
3-
import { databaseNamespace } from '../utils';
3+
import { databaseNamespace, emitWarningOnce } from '../utils';
44
import { OP_QUERY, OP_GETMORE, OP_KILL_CURSORS, OP_MSG } from './wire_protocol/constants';
55
import type { Long, Document, BSONSerializeOptions } from '../bson';
66
import type { ClientSession } from '../sessions';
@@ -826,14 +826,15 @@ export class BinMsg {
826826

827827
while (this.index < this.data.length) {
828828
const payloadType = this.data.readUInt8(this.index++);
829-
if (payloadType === 1) {
830-
throw new MongoError('Type 1 payload'); // ???
831-
} else if (payloadType === 0) {
829+
if (payloadType === 0) {
832830
const bsonSize = this.data.readUInt32LE(this.index);
833831
const bin = this.data.slice(this.index, this.index + bsonSize);
834832
this.documents.push(raw ? bin : BSON.deserialize(bin, _options));
835833

836834
this.index += bsonSize;
835+
} else if (payloadType === 1) {
836+
// It was decided that no driver makes use of payload type 1
837+
throw new MongoError('OP_MSG Payload Type 1 detected unsupported protocol')
837838
}
838839
}
839840

src/operations/add_user.ts

-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ export class AddUserOperation extends CommandOperation<Document> {
7575
roles = Array.isArray(options.roles) ? options.roles : [options.roles];
7676
}
7777

78-
if (roles.length === 0) {
79-
// If not roles defined throw error
80-
}
81-
8278
const digestPassword = getTopology(db).lastIsMaster().maxWireVersion >= 7;
8379

8480
let userPassword = password;

0 commit comments

Comments
 (0)