Skip to content

Commit 7281291

Browse files
authored
transport/mongodb: normalize URI options to lowercase and flatten single-item lists Normalize MongoDB URI option keys to lowercase and flatten single-item lists returned by uri_parser.parse_uri. This ensures that query params like replicaSet=test_rs are accessible as options['replicaset'] with a scalar value, matching existing Kombu tests and expectations. Normalization is performed before _prepare_client_options so that lowercased keys (e.g., readpreference) are properly handled.
1 parent 4c9fb4b commit 7281291

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

kombu/transport/mongodb.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ def _parse_uri(self, scheme='mongodb://'):
321321
if self.connect_timeout else None),
322322
}
323323
options.update(parsed['options'])
324+
normalized = {}
325+
for k, v in options.items():
326+
val = v[0] if isinstance(v, list) and len(v) == 1 else v
327+
normalized[k] = val
328+
lk = k.lower()
329+
if lk not in normalized:
330+
normalized[lk] = val
331+
options = normalized
324332
options = self._prepare_client_options(options)
325333

326334
if 'tls' in options:

0 commit comments

Comments
 (0)