{"record":{"id":"1884f7dd98731ce8","repo":"mongodb/node-mongodb-native","slug":"cause-message","errorCode":null,"errorMessage":"${cause.message}","messagePattern":"\\$\\{cause\\.message\\}","errorType":"exception","errorClass":"MongoUnexpectedServerResponseError","httpStatus":null,"severity":"error","filePath":"src/cmap/wire_protocol/responses.ts","lineNumber":95,"sourceCode":"  public override get<const T extends keyof JSTypeOf>(\n    name: string | number,\n    as: T,\n    required?: false\n  ): JSTypeOf[T] | null;\n  public override get<const T extends keyof JSTypeOf>(\n    name: string | number,\n    as: T,\n    required: true\n  ): JSTypeOf[T];\n  public override get<const T extends keyof JSTypeOf>(\n    name: string | number,\n    as: T,\n    required?: boolean\n  ): JSTypeOf[T] | null {\n    try {\n      return super.get(name, as, required);\n    } catch (cause) {\n      throw new MongoUnexpectedServerResponseError(cause.message, { cause });\n    }\n  }\n\n  static is(value: unknown): value is MongoDBResponse {\n    return value instanceof MongoDBResponse;\n  }\n\n  static make(bson: Uint8Array) {\n    const elements = parseToElementsToArray(bson, 0);\n    const isError = isErrorResponse(bson, elements);\n    return isError\n      ? new MongoDBResponse(bson, 0, false, elements)\n      : new this(bson, 0, false, elements);\n  }\n\n  // {ok:1}\n  static empty = new MongoDBResponse(new Uint8Array([13, 0, 0, 0, 16, 111, 107, 0, 1, 0, 0, 0, 0]));\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/cmap/wire_protocol/responses.ts#L77-L113","documentation":"MongoDBResponse.get wraps any BSONError thrown by the underlying OnDemandDocument.get and re-throws it as a MongoUnexpectedServerResponseError, preserving the original as `cause`. The message is the wrapped error's message. It signals that a server response did not contain a field, or contained a wrong-typed field, that the driver requires to continue. This is the user-visible form of errors 146/147 when responses are parsed.","triggerScenarios":"Fires at src/cmap/wire_protocol/responses.ts:95 whenever MongoDBResponse.get(name, as, required) calls super.get and that throws. Common during SDAM hello/isMaster parsing, command response parsing, or any internal required-field read on a server BSON reply.","commonSituations":"Connecting a newer driver to an older, unsupported MongoDB server; a proxy/load-balancer rewriting or truncating responses; a server bug omitting a required field; network corruption. Frequently seen after a server downgrade or during a rolling upgrade mismatch.","solutions":["Check the MongoDB server version meets the driver's minimum supported version (see driver compatibility matrix).","Upgrade both driver and server to compatible, current releases.","Connect directly to mongod/mongos, bypassing proxies.","If it persists, capture the failing command/response and file a driver issue with versions of both sides."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await collection.find({}).toArray();\n} catch (error) {\n  if (error instanceof MongoUnexpectedServerResponseError) {\n  }\n}","preventionTips":["Always run a driver version compatible with your server version.","Connect directly to mongod/mongos when diagnosing.","Upgrade both sides together during rolling maintenance."],"tags":["wire-protocol","version-mismatch","server-response","sdam"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}