mongodb/node-mongodb-native · error · MongoParseError
not supported
Error message
${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported What it means
After collecting every URI and object option, the driver computes the set of keys that are not in the known OPTIONS table and rejects them. This catches typos and unsupported options early (fail-fast) rather than silently ignoring them. The message pluralizes 'option(s)' and 'is/are' based on the count.
Solutions
- Check the offending key name against the current driver option list in the docs.
- Remove or rename the unsupported key.
- If the option exists under a different name (e.g. maxPoolSize -> maxPoolSize is valid; check aliases), update accordingly.
Example fix
// before
new MongoClient('mongodb://h/db?maxIdleTimeMS=60000');
// after
new MongoClient('mongodb://h/db?maxIdleTimeMS=60000'); // if valid; otherwise remove/rename per docs Defensive patterns
Strategy: validation
Validate before calling
// Keep an allow-list derived from the driver's option names and check keys against it.
import { OPTIONS } from './driver-options'; // project-curated list
function assertSupportedOptions(keys: string[]) {
const known = new Set(Object.keys(OPTIONS).map(k => k.toLowerCase()));
const bad = keys.filter(k => !known.has(k.toLowerCase()));
if (bad.length) throw new Error(`Unsupported options: ${bad.join(', ')}`);
} Prevention
- Type the options object as MongoClientOptions so the compiler rejects unknown keys.
- Run driver upgrades with attention to renamed/removed options.
When it happens
Trigger: Any URI query key or options object key that is not a registered driver option. Common: 'sslProtocal', 'maxPoolSize' (renamed), 'reconnectInterval', or vendor-specific keys from another driver.
Common situations: Cross-driver config drift (e.g. Java/.NET option names), outdated tutorial snippets, or auto-generated option objects that include extra metadata fields.
Related errors
- All values of tls/ssl must be the same.
- Auth mechanism property ALLOWED_HOSTS is not allowed in the…
- authMechanism requires an authSource of '$external
- authMechanism one of
- AuthMechanismProperties must be an object
AI-assisted analysis of mongodb/node-mongodb-native@dce7939f86 (2026-08-11).
Data as JSON: /api/errors/ef5538d05458d5d8.
Report an issue: GitHub.
Appendix: source
Thrown at src/connection_string.ts:369
if (allProvidedOptions.has('tls') || allProvidedOptions.has('ssl')) {
const tlsAndSslOpts = (allProvidedOptions.get('tls') || [])
.concat(allProvidedOptions.get('ssl') || [])
.map(getBoolean.bind(null, 'tls/ssl'));
if (new Set(tlsAndSslOpts).size !== 1) {
throw new MongoParseError('All values of tls/ssl must be the same.');
}
}
checkTLSOptions(allProvidedOptions);
const unsupportedOptions = setDifference(
allProvidedKeys,
Array.from(Object.keys(OPTIONS)).map(s => s.toLowerCase())
);
if (unsupportedOptions.size !== 0) {
const optionWord = unsupportedOptions.size > 1 ? 'options' : 'option';
const isOrAre = unsupportedOptions.size > 1 ? 'are' : 'is';
throw new MongoParseError(
`${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported`
);
}
// Option parsing and setting
for (const [key, descriptor] of Object.entries(OPTIONS)) {
const values = allProvidedOptions.get(key);
if (!values || values.length === 0) {
if (DEFAULT_OPTIONS.has(key)) {
setOption(mongoOptions, key, descriptor, [DEFAULT_OPTIONS.get(key)]);
}
} else {
const { deprecated } = descriptor;
if (deprecated) {
const deprecatedMsg = typeof deprecated === 'string' ? `: ${deprecated}` : '';
emitWarning(`${key} is a deprecated option${deprecatedMsg}`);
}View on GitHub (pinned to dce7939f86)