{"id":"95c68f5dfa3d0cec","repo":"mongodb/node-mongodb-native","slug":"unexpected-topology-type-topologydescription-ty","errorCode":null,"errorMessage":"unexpected topology type: ${topologyDescription.type} (this should never happen).  Please file a bug in the Node driver Jira project.","messagePattern":"unexpected topology type: (.+?) \\(this should never happen\\)\\.  Please file a bug in the Node driver Jira project\\.","errorType":"exception","errorClass":"MongoRuntimeError","httpStatus":null,"severity":"error","filePath":"src/sdam/server_selection.ts","lineNumber":409,"sourceCode":"    deprioritized: DeprioritizedServers\n  ): ServerDescription[] {\n    switch (topologyDescription.type) {\n      case 'Single':\n        return latencyWindowReducer(topologyDescription, servers.filter(knownFilter));\n      case 'ReplicaSetNoPrimary':\n      case 'ReplicaSetWithPrimary':\n        return secondarySelector(readPreference, topologyDescription, servers, deprioritized);\n      case 'Sharded': {\n        const selectable = filterDeprioritized(servers, deprioritized);\n        return latencyWindowReducer(topologyDescription, selectable.filter(knownFilter));\n      }\n      case 'Unknown':\n        return [];\n      case 'LoadBalanced':\n        return servers.filter(loadBalancerFilter);\n      default: {\n        const _exhaustiveCheck: never = topologyDescription.type;\n        throw new MongoRuntimeError(\n          `unexpected topology type: ${topologyDescription.type} (this should never happen).  Please file a bug in the Node driver Jira project.`\n        );\n      }\n    }\n  };\n}\n","sourceCodeStart":391,"sourceCodeEnd":416,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/sdam/server_selection.ts#L391-L416","documentation":"The `default` branch of the topology-type switch in `readPreferenceServerSelector`, guarded by a `never` exhaustive check on `topologyDescription.type` (server_selection.ts:407). It indicates an SDAM topology type the selector does not recognize; the message asks for a bug report. Under normal operation the type is always one of Single, ReplicaSetNoPrimary, ReplicaSetWithPrimary, Sharded, Unknown, or LoadBalanced.","triggerScenarios":"A new topology type was introduced without a selector case; internal state corruption setting type to an out-of-enum value; an incompatible driver fork.","commonSituations":"Running an outdated driver against a newer server topology feature; monkeypatching SDAM internals.","solutions":["Update to the latest driver release that supports your topology.","Avoid patching SDAM internals; if necessary, re-run with stock internals to confirm.","File a bug with the driver version, topology, and the offending type value."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await client.db().command({ ping: 1 });\n} catch (e) {\n  if (e instanceof MongoRuntimeError && /unexpected topology type/.test(e.message)) {\n    // update driver and report; this is an internal invariant\n  }\n  throw e;\n}","preventionTips":["Keep the driver version current with your server topology.","Do not monkeypatch SDAM internals.","Report occurrences with the topology description and driver version."],"tags":["internal","bug","sdam"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}