{"record":{"id":"d77f4fe6974268ee","repo":"mongodb/node-mongodb-native","slug":"option-mongodblogcomponentseverities-does-not-su","errorCode":null,"errorMessage":"Option 'mongodbLogComponentSeverities' does not support ${v} as a value for ${k}","messagePattern":"Option 'mongodbLogComponentSeverities' does not support (.+?) as a value for (.+?)","errorType":"exception","errorClass":"MongoAPIError","httpStatus":null,"severity":"error","filePath":"src/connection_string.ts","lineNumber":1271,"sourceCode":"  },\n  mongodbLogComponentSeverities: {\n    transform({ values: [value] }) {\n      if (typeof value !== 'object' || !value) {\n        throw new MongoAPIError(`Option 'mongodbLogComponentSeverities' must be a non-null object`);\n      }\n      for (const [k, v] of Object.entries(value)) {\n        if (typeof v !== 'string' || typeof k !== 'string') {\n          throw new MongoAPIError(\n            `User input for option 'mongodbLogComponentSeverities' object cannot include a non-string key or value`\n          );\n        }\n        if (!Object.values(MongoLoggableComponent).some(val => val === k) && k !== 'default') {\n          throw new MongoAPIError(\n            `User input for option 'mongodbLogComponentSeverities' contains invalid key: ${k}`\n          );\n        }\n        if (!Object.values(SeverityLevel).some(val => val === v)) {\n          throw new MongoAPIError(\n            `Option 'mongodbLogComponentSeverities' does not support ${v} as a value for ${k}`\n          );\n        }\n      }\n      return value;\n    }\n  },\n  mongodbLogMaxDocumentLength: { type: 'uint' },\n  // Custom types for modifying core behavior\n  connectionType: { type: 'any' },\n  srvPoller: { type: 'any' },\n  // Accepted Node.js Options\n  allowPartialTrustChain: { type: 'any' },\n  minDHSize: { type: 'any' },\n  pskCallback: { type: 'any' },\n  secureContext: { type: 'any' },\n  enableTrace: { type: 'any' },\n  requestCert: { type: 'any' },","sourceCodeStart":1253,"sourceCodeEnd":1289,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/connection_string.ts#L1253-L1289","documentation":"Each value in `mongodbLogComponentSeverities` must be a recognized severity. At src/connection_string.ts:1270 the driver checks `Object.values(SeverityLevel).some(val => val === v)`. SeverityLevel (frozen at src/mongo_logger.ts:85) contains: `emergency`, `alert`, `critical`, `error`, `warn`, `notice`, `info`, `debug`, `trace`, `off`. Any other value throws MongoAPIError at src/connection_string.ts:1271.","triggerScenarios":"Passing `{ command: 'warning' }` (the canonical name is `warn`, not `warning`); `{ command: 'information' }`; `{ command: 'verbose' }`; `{ command: 'WARNING' }` (case mismatch).","commonSituations":"Using full-word severity names from other loggers (pino/winston use 'warn' too, but 'warning' is a common typo); using uppercase from RFC 5424; using numeric levels.","solutions":["Use exactly one of: emergency, alert, critical, error, warn, notice, info, debug, trace, off (lowercase).","Note `warn` — not `warning` — and `info` — not `information`.","Set a component to `off` to silence it."],"exampleFix":"// before\nnew MongoClient(uri, { mongodbLogComponentSeverities: { command: 'warning' } });\n\n// after\nnew MongoClient(uri, { mongodbLogComponentSeverities: { command: 'warn' } });","handlingStrategy":"validation","validationCode":"import { SeverityLevel } from 'mongodb';\nconst VALUES = Object.values(SeverityLevel); // emergency, alert, critical, error, warn, notice, info, debug, trace, off\nif (opts.mongodbLogComponentSeverities) {\n  for (const [k, v] of Object.entries(opts.mongodbLogComponentSeverities as Record<string, string>)) {\n    if (!VALUES.includes(v as any)) throw new Error(`invalid severity ${v} for ${k}`);\n  }\n}","typeGuard":"function isSeverityValue(v: unknown): boolean { return typeof v === 'string' && Object.values(SeverityLevel).includes(v as any); }","tryCatchPattern":"try { client = new MongoClient(uri, opts); } catch (e) { if (e instanceof MongoAPIError && /does not support/.test(e.message)) { opts.mongodbLogComponentSeverities = { default: 'info' }; client = new MongoClient(uri, opts); } else throw e; }","preventionTips":["Use `warn` not `warning`, `info` not `information`.","Build the allowed-values list from Object.values(SeverityLevel).","Use `off` to silence a component."],"tags":["logging","configuration"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}