{"record":{"id":"72afc75ae54395cb","repo":"mongodb/node-mongodb-native","slug":"must-request-either-bigint-or-long-for-int64-deser","errorCode":null,"errorMessage":"Must request either bigint or Long for int64 deserialization","messagePattern":"Must request either bigint or Long for int64 deserialization","errorType":"exception","errorClass":"MongoAPIError","httpStatus":null,"severity":"error","filePath":"src/connection_string.ts","lineNumber":249,"sourceCode":"  }\n  override delete(k: string): boolean {\n    return super.delete(k.toLowerCase());\n  }\n}\n\nexport function parseOptions(\n  uri: string,\n  mongoClient: MongoClient | MongoClientOptions | undefined = undefined,\n  options: MongoClientOptions = {}\n): MongoOptions {\n  if (mongoClient != null && !(mongoClient instanceof MongoClient)) {\n    options = mongoClient;\n    mongoClient = undefined;\n  }\n\n  // validate BSONOptions\n  if (options.useBigInt64 && typeof options.promoteLongs === 'boolean' && !options.promoteLongs) {\n    throw new MongoAPIError('Must request either bigint or Long for int64 deserialization');\n  }\n\n  if (options.useBigInt64 && typeof options.promoteValues === 'boolean' && !options.promoteValues) {\n    throw new MongoAPIError('Must request either bigint or Long for int64 deserialization');\n  }\n\n  const url = new ConnectionString(uri);\n  const { hosts, isSRV } = url;\n\n  const mongoOptions = Object.create(null);\n\n  mongoOptions.hosts = isSRV ? [] : hosts.map(HostAddress.fromString);\n\n  const urlOptions = new CaseInsensitiveMap<unknown[]>();\n\n  if (url.pathname !== '/' && url.pathname !== '') {\n    const dbName = decodeURIComponent(\n      url.pathname[0] === '/' ? url.pathname.slice(1) : url.pathname","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/connection_string.ts#L231-L267","documentation":"BSON int64 deserialization mode conflict. useBigInt64 asks the driver to materialize 64-bit ints as JS bigint, but promoteLongs=false tells it NOT to return Long objects either. Together they leave no valid representation for int64, so the driver refuses to construct options. The same message is reused for the promoteValues=false case at line 253.","triggerScenarios":"Calling new MongoClient(uri, { useBigInt64: true, promoteLongs: false }). The check runs at the top of parseOptions before any URI parsing.","commonSituations":"Enabling useBigInt64 for native bigint support while keeping an older config that set promoteLongs: false to force string/number promotion.","solutions":["Drop promoteLongs: false (allow it to default to true) when using useBigInt64.","Or remove useBigInt64 if you intentionally want non-Long promotion."],"exampleFix":"// before\nnew MongoClient(uri, { useBigInt64: true, promoteLongs: false });\n// after\nnew MongoClient(uri, { useBigInt64: true });","handlingStrategy":"validation","validationCode":"function assertBigIntOptions(opts: { useBigInt64?: boolean; promoteLongs?: boolean; promoteValues?: boolean }) {\n  if (opts.useBigInt64 && typeof opts.promoteLongs === 'boolean' && !opts.promoteLongs) {\n    throw new Error('useBigInt64 requires promoteLongs !== false');\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When enabling useBigInt64, audit and remove legacy promoteLongs:false settings.","Document the int64 representation choice once per project."],"tags":["bson","options","validation","bigint"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}