Repository navigation
fix(mongodb): don't add a slash after the first host in as_uri() - #2736
Open
LuisFigueroaG wants to merge 2 commits into
Open
LuisFigueroaG wants to merge 2 commits into
LuisFigueroaG wants to merge 2 commits into
Conversation
With more than one host in the URL, as_uri() sanitized the first host on its own, and as_url() appends an empty path to it, so mongodb://user:pass@h1,h2/db came out as mongodb://user:**@h1/,h2/db. Strip that slash, and pass the mask through instead of always using the default one.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2736 +/- ##
==========================================
+ Coverage 85.11% 85.14% +0.02%
==========================================
Files 80 80
Lines 11357 11358 +1
Branches 1362 1362
==========================================
+ Hits 9667 9671 +4
+ Misses 1470 1468 -2
+ Partials 220 219 -1 ☔ View full report in Codecov by Harness. |
auvipy
self-requested a review
October 10, 2026 08:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With more than one host in the broker URL,
Transport.as_uri()sanitizes the first host on its own, andas_url()appends an empty path to it. Somongodb://user:pass@h1:27017,h2:27017/db?replicaSet=rs0was displayed asmongodb://user:**@h1:27017/,h2:27017/db?replicaSet=rs0, for example in the Celery worker banner. Themaskargument was also ignored, soas_uri(mask=...)always used**.This strips the extra slash and passes
maskthrough. Added tests for single-host, replica-set and no-credentials URLs, and for a custom mask.Backward compatibility: this only affects the displayed, sanitized string.
include_password=Truestill returns the URL unchanged, and connecting (_parse_uri) isn't touched. Single-host URLs give the same output as before unless a custom mask is passed.