{"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/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/connection_string.ts#L1253-L1289","documentation":"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.","triggerScenarios":"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.","commonSituations":"Using severity names from other loggers (pino/winston use 'trace'/'fatal'/'silent'); uppercase from env vars; assuming syslog numeric levels are accepted as strings.","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."],"exampleFix":"// before\nnew MongoClient(uri, { mongodbLogComponentSeverities: { command: 'DEBUG' } });\n// after\nnew MongoClient(uri, { mongodbLogComponentSeverities: { command: 'debug' } });","handlingStrategy":"validation","validationCode":"import { SeverityLevel } from 'mongodb';\nconst VALID = new Set(Object.values(SeverityLevel));\nfunction validValues(o) { return Object.values(o).every(v => VALID.has(v)); }","typeGuard":"function isValidSeverity(v): v is string {\n  return Object.values(SeverityLevel).includes(v as any);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["logging","options","configuration","enum-validation"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}