{"record":{"id":"65fc76c57151825d","repo":"mongodb/node-mongodb-native","slug":"op-msg-payload-type-1-detected-unsupported-protoco","errorCode":null,"errorMessage":"OP_MSG Payload Type 1 detected unsupported protocol","messagePattern":"OP_MSG Payload Type 1 detected unsupported protocol","errorType":"exception","errorClass":"MongoRuntimeError","httpStatus":null,"severity":"critical","filePath":"src/cmap/commands.ts","lineNumber":751,"sourceCode":"    this.index = 4;\n\n    while (this.index < this.data.length) {\n      const payloadType = this.data[this.index++];\n      if (payloadType === 0) {\n        // BSON spec specifies that this is a 32-bit signed integer: https://bsonspec.org/spec.html#:~:text=%3A%3A%3D-,int32,-e_list%20unsigned_byte(0\n        // While allowing negative sizes seems odd, in practice we never expect a negative size. Also, the server's 16mb limit for BSON documents leaves plenty\n        // of room in an int32 to store a document of the max BSON size that the server supports\n        const bsonSize = readInt32LE(this.data, this.index);\n        const bin = this.data.subarray(this.index, this.index + bsonSize);\n\n        this.sections.push(bin);\n\n        this.index += bsonSize;\n      } else if (payloadType === 1) {\n        // It was decided that no driver makes use of payload type 1\n\n        // TODO(NODE-3483): Replace with MongoDeprecationError\n        throw new MongoRuntimeError('OP_MSG Payload Type 1 detected unsupported protocol');\n      }\n    }\n\n    this.parsed = true;\n\n    return this.sections[0];\n  }\n}\n\nconst MESSAGE_HEADER_SIZE = 16;\nconst COMPRESSION_DETAILS_SIZE = 9; // originalOpcode + uncompressedSize, compressorID\n\n/**\n * @internal\n */\nexport interface OpCompressesRequestOptions {\n  zlibCompressionLevel: number;\n  agreedCompressor: CompressorName;","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/cmap/commands.ts#L733-L769","documentation":"Thrown as a MongoRuntimeError in OpMsgResponse.parse() when an OP_MSG response section has payloadType === 1. The OP_MSG spec defines two payload types: type 0 (a single BSON document) and type 1 (a document sequence / Section 1). The driver supports sending type-1 sections but, per an explicit code comment ('no driver makes use of payload type 1'), it does not support receiving them. A type-1 section in a response is therefore treated as an unsupported protocol.","triggerScenarios":"A MongoDB server (or proxy) returns an OP_MSG response containing a payload type-1 section. Genuine MongoDB servers do not send type-1 responses for commands the driver issues, so this implies a non-conformant server, a custom backend, or wire-protocol corruption.","commonSituations":"Pointing the driver at a MongoDB-compatible but non-conformant service (e.g. a mock server, Amazon DocumentDB in certain modes, or a custom proxy) that emits type-1 sections; corrupted response bytes that happen to decode as payload type 1.","solutions":["Point the driver at a genuine MongoDB server (community or Atlas)","If using a MongoDB-compatible service, check its compatibility notes or upgrade it","Capture the failing command and response and report it to the service vendor"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await client.db().command({ ping: 1 }); } catch (e) {\n  if (e instanceof MongoRuntimeError && /Payload Type 1/.test(e.message)) {\n    // server/proxy is non-conformant; switch to a genuine MongoDB endpoint\n  }\n  throw e;\n}","preventionTips":["Use a genuine MongoDB server (community or Atlas) rather than a non-conformant emulator","Keep proxies transparent to the wire protocol","Validate MongoDB-compatible services against the OP_MSG spec before production use"],"tags":["wire-protocol","op-msg","compatibility","corruption"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}