mongodb/node-mongodb-native · error · MongoAPIError
Option 'mongodbLogComponentSeverities' does not support ${v}
Error message
Option 'mongodbLogComponentSeverities' does not support ${v} as a value for ${k} What it means
Thrown when a value in mongodbLogComponentSeverities is not a member of the SeverityLevel enum. SeverityLevel is the set of allowed log severities (e.g. 'emergency', 'alert', 'critical', 'error', 'warning', 'info', 'debug'). The error names both the bad value and its key.
Source
Thrown at src/connection_string.ts:1271
},
mongodbLogComponentSeverities: {
transform({ values: [value] }) {
if (typeof value !== 'object' || !value) {
throw new MongoAPIError(`Option 'mongodbLogComponentSeverities' must be a non-null object`);
}
for (const [k, v] of Object.entries(value)) {
if (typeof v !== 'string' || typeof k !== 'string') {
throw new MongoAPIError(
`User input for option 'mongodbLogComponentSeverities' object cannot include a non-string key or value`
);
}
if (!Object.values(MongoLoggableComponent).some(val => val === k) && k !== 'default') {
throw new MongoAPIError(
`User input for option 'mongodbLogComponentSeverities' contains invalid key: ${k}`
);
}
if (!Object.values(SeverityLevel).some(val => val === v)) {
throw new MongoAPIError(
`Option 'mongodbLogComponentSeverities' does not support ${v} as a value for ${k}`
);
}
}
return value;
}
},
mongodbLogMaxDocumentLength: { type: 'uint' },
// Custom types for modifying core behavior
connectionType: { type: 'any' },
srvPoller: { type: 'any' },
// Accepted Node.js Options
allowPartialTrustChain: { type: 'any' },
minDHSize: { type: 'any' },
pskCallback: { type: 'any' },
secureContext: { type: 'any' },
enableTrace: { type: 'any' },
requestCert: { type: 'any' },View on GitHub (pinned to 3366c21a63)
Solutions
- Use only SeverityLevel values: 'emergency' | 'alert' | 'critical' | 'error' | 'warning' | 'info' | 'debug'.
- Lowercase env-var input before passing: severity.toLowerCase().
- If unsure, use 'info' or 'debug' which are the most common valid choices.
Example fix
// before
new MongoClient(uri, { mongodbLogComponentSeverities: { command: 'DEBUG' } });
// after
new MongoClient(uri, { mongodbLogComponentSeverities: { command: 'debug' } }); Defensive patterns
Strategy: validation
Validate before calling
import { SeverityLevel } from 'mongodb';
const VALID = new Set(Object.values(SeverityLevel));
function validValues(o) { return Object.values(o).every(v => VALID.has(v)); } Type guard
function isValidSeverity(v): v is string {
return Object.values(SeverityLevel).includes(v as any);
} Prevention
- Derive allowed severities from the SeverityLevel enum, not from memory.
- Lowercase env-var input: severity.toLowerCase().
- Avoid 'trace'/'fatal'/'silent' from other loggers — they are not valid here.
When it happens
Trigger: Passing { command: 'trace' } (not a valid SeverityLevel), { command: 'DEBUG' } (wrong case), { command: 'verbose' }, or any non-enum string. Case is significant — the enum values are lowercase.
Common situations: Using severity names from other loggers (pino/winston use 'trace'/'fatal'/'silent'); uppercase from env vars; assuming syslog numeric levels are accepted as strings.
Related errors
- User input for option 'mongodbLogComponentSeverities' contai
- Option 'mongodbLogPath' must be of type 'stderr' | 'stdout'
- Option 'mongodbLogComponentSeverities' must be a non-null ob
- User input for option 'mongodbLogComponentSeverities' object
- Descriptors missing a type must define a transform
AI-assisted analysis of mongodb/node-mongodb-native@3366c21a63 (2026-08-04).
Data as JSON: /data/errors/d77f4fe6974268ee.json.
Report an issue: GitHub.