{"id":"ef5538d05458d5d8","repo":"mongodb/node-mongodb-native","slug":"optionword-array-from-unsupportedoptions-joi","errorCode":null,"errorMessage":"${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported","messagePattern":"(.+?) (.+?) (.+?) not supported","errorType":"exception","errorClass":"MongoParseError","httpStatus":null,"severity":"error","filePath":"src/connection_string.ts","lineNumber":369,"sourceCode":"  if (allProvidedOptions.has('tls') || allProvidedOptions.has('ssl')) {\n    const tlsAndSslOpts = (allProvidedOptions.get('tls') || [])\n      .concat(allProvidedOptions.get('ssl') || [])\n      .map(getBoolean.bind(null, 'tls/ssl'));\n    if (new Set(tlsAndSslOpts).size !== 1) {\n      throw new MongoParseError('All values of tls/ssl must be the same.');\n    }\n  }\n\n  checkTLSOptions(allProvidedOptions);\n\n  const unsupportedOptions = setDifference(\n    allProvidedKeys,\n    Array.from(Object.keys(OPTIONS)).map(s => s.toLowerCase())\n  );\n  if (unsupportedOptions.size !== 0) {\n    const optionWord = unsupportedOptions.size > 1 ? 'options' : 'option';\n    const isOrAre = unsupportedOptions.size > 1 ? 'are' : 'is';\n    throw new MongoParseError(\n      `${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported`\n    );\n  }\n\n  // Option parsing and setting\n\n  for (const [key, descriptor] of Object.entries(OPTIONS)) {\n    const values = allProvidedOptions.get(key);\n    if (!values || values.length === 0) {\n      if (DEFAULT_OPTIONS.has(key)) {\n        setOption(mongoOptions, key, descriptor, [DEFAULT_OPTIONS.get(key)]);\n      }\n    } else {\n      const { deprecated } = descriptor;\n      if (deprecated) {\n        const deprecatedMsg = typeof deprecated === 'string' ? `: ${deprecated}` : '';\n        emitWarning(`${key} is a deprecated option${deprecatedMsg}`);\n      }","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/connection_string.ts#L351-L387","documentation":"Thrown when the union of URI query params and options object keys contains any key not present in the driver's OPTIONS table (connection_string.ts:362-372). This catches typos, removed options, and options that belong to other drivers. The message interpolates the offending key(s).","triggerScenarios":"Passing a misspelled option like { maxPoolSzie: 10 }, a removed option like { autoReconnect: true }, or a URI param like '?bufferMaxEntries=5'. Any single unsupported key triggers it; multiple produce 'options X, Y are not supported'.","commonSituations":"Copy-pasting options from old tutorials or other drivers (e.g. mongoose-only keys); typos in option names; upgrading the driver and using options removed in v4/v5 (autoReconnect, bufferMaxEntries, reconnectInterval).","solutions":["Inspect the offending key name(s) in the error message and compare against the current MongoClientOptions type.","Fix typos (e.g. maxPoolSzie -> maxPoolSize).","Remove options that no longer exist; find the modern equivalent (e.g. bufferMaxEntries was removed; use maxPoolSize and handle errors).","Run a typecheck (npm run check:ts) so TypeScript flags unknown options before runtime."],"exampleFix":"// before\nconst c = new MongoClient(uri, { maxPoolSzie: 10, autoReconnect: true });\n// after\nconst c = new MongoClient(uri, { maxPoolSize: 10 });","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"import type { MongoClientOptions } from 'mongodb';\nfunction isKnownOption(opts: unknown): opts is MongoClientOptions {\n  // compile-time: excess-property checks on object literals surface unknown keys\n  return typeof opts === 'object' && opts !== null;\n}\n// Rely on TS excess-property checks: declare the param as MongoClientOptions, not 'any'.","tryCatchPattern":"try { client = new MongoClient(uri, opts); }\ncatch (e) {\n  if (e instanceof MongoParseError && /not supported/.test(e.message)) {\n    const bad = e.message.match(/(?:option|options) (.+?) (?:is|are) not supported/)?.[1].split(', ') ?? [];\n    bad.forEach(k => delete opts[k]);\n    client = new MongoClient(uri, opts);\n  } else throw e;\n}","preventionTips":["Type all connection config as MongoClientOptions so excess properties fail at compile time.","Run `npm run check:ts` in CI.","Avoid building options from untyped env-var dictionaries without a schema."],"tags":["connection-string","configuration","typo","migration"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}