{"id":"a271a31adfe455fa","repo":"mongodb/node-mongodb-native","slug":"serverdescription-must-be-provided-with-a-non-empt","errorCode":null,"errorMessage":"ServerDescription must be provided with a non-empty address","messagePattern":"ServerDescription must be provided with a non-empty address","errorType":"exception","errorClass":"MongoRuntimeError","httpStatus":null,"severity":"error","filePath":"src/sdam/server_description.ts","lineNumber":103,"sourceCode":"  iscryptd: boolean;\n\n  // NOTE: does this belong here? It seems we should gossip the cluster time at the CMAP level\n  $clusterTime?: ClusterTime;\n\n  /**\n   * Create a ServerDescription\n   * @internal\n   *\n   * @param address - The address of the server\n   * @param hello - An optional hello response for this server\n   */\n  constructor(\n    address: HostAddress | string,\n    hello?: Document,\n    options: ServerDescriptionOptions = {}\n  ) {\n    if (address == null || address === '') {\n      throw new MongoRuntimeError('ServerDescription must be provided with a non-empty address');\n    }\n\n    this.address =\n      typeof address === 'string'\n        ? HostAddress.fromString(address).toString() // Use HostAddress to normalize\n        : address.toString();\n    this.type = parseServerType(hello, options);\n    this.hosts = hello?.hosts?.map((host: string) => host.toLowerCase()) ?? [];\n    this.passives = hello?.passives?.map((host: string) => host.toLowerCase()) ?? [];\n    this.arbiters = hello?.arbiters?.map((host: string) => host.toLowerCase()) ?? [];\n    this.tags = hello?.tags ?? {};\n    this.minWireVersion = hello?.minWireVersion ?? 0;\n    this.maxWireVersion = hello?.maxWireVersion ?? 0;\n    this.roundTripTime = options?.roundTripTime ?? -1;\n    this.minRoundTripTime = options?.minRoundTripTime ?? 0;\n    this.lastUpdateTime = processTimeMS();\n    this.lastWriteDate = hello?.lastWrite?.lastWriteDate ?? 0;\n    // NOTE: This actually builds the stack string instead of holding onto the getter and all its","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/sdam/server_description.ts#L85-L121","documentation":"The `ServerDescription` constructor requires a non-empty address; it throws when the address is null, undefined, or an empty string (server_description.ts:102). ServerDescription is an `@internal` class used by SDAM to represent a discovered or seed server, and every description must carry a resolvable host:port address.","triggerScenarios":"Internally constructing a ServerDescription from an empty host string or null seed; a malformed seedlist entry; a hello/SDAM response that yields an empty host during topology updates.","commonSituations":"Passing a blank host in the connection string (`mongodb:///defaultauthdb`); a seedlist array containing an empty string; programmatic topology construction with an unparsed address.","solutions":["Ensure every host in the connection string / seedlist is a non-empty `host:port` value.","Validate addresses with `HostAddress.fromString(addr)` before use and skip empties.","If surfaced from internal SDAM, update the driver and report it with the server hello response."],"exampleFix":"// before\nnew ServerDescription('')\n// after\nnew ServerDescription(HostAddress.fromString('localhost:27017'))","handlingStrategy":"validation","validationCode":"function assertHost(addr) {\n  if (addr == null || addr === '') throw new TypeError('host must be non-empty');\n  return typeof addr === 'string' ? HostAddress.fromString(addr) : addr;\n}","typeGuard":"function isNonEmptyHost(addr) {\n  return typeof addr === 'string' ? addr.trim() !== '' : addr instanceof HostAddress;\n}","tryCatchPattern":null,"preventionTips":["Parse connection strings with the driver rather than splitting hosts manually.","Skip empty host entries when building seedlists.","Validate host strings at config load time."],"tags":["sdam","configuration","internal"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}