Repository navigation
MongoDB fails to connect when credentials contain a space - #52121
Merged
snicoll merged 1 commit intoOct 12, 2026
Merged
Conversation
Member
|
@prashantpiyush1111 your comment appears to be AI generated. As such, it isn't helpful. If we want an AI's review of the changes, we can get one ourselves. What is helpful is bringing a different human perspective to a change as we have very limited access to those. |
|
@wilkinsona Thanks for the feedback. I know what you mean. I was going to go through the changes and post my observations. I agree that reviews are most helpful when they are from an independent human point of view. I’ll keep this in mind and will try to focus on providing specific personal observations in future reviews. |
Encode spaces as percent escapes when creating a connection string from MongoDB username and password properties so the driver does not interpret them as literal plus signs. Reuse the string encoder for passwords and add regression tests for both credential properties. See spring-projectsgh-52121 Signed-off-by: Jialin Chen <cccll2019@gmail.com>
snicoll
force-pushed
the
fix/mongodb-credential-spaces
branch
from
October 12, 2026 13:17
9d37e52 to
98fd227
Compare
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.
When
spring.mongodb.usernameorspring.mongodb.passwordcontains a space,PropertiesMongoConnectionDetailsencodes it as+. The MongoDB driver treats that character as a literal plus sign, so a configured password such asmy secretbecomesmy+secretin the parsed credentials.Encode spaces as
%20, matching the Docker Compose handling added in #51939, and reuse the string encoder for passwords. Add regression tests for both properties covering spaces, literal plus signs, a mixture of the two, and reserved characters.Validation:
:module:spring-boot-mongodb:test: 108 tests passed.:module:spring-boot-mongodb:checkFormat,:module:spring-boot-mongodb:checkstyleMain, and:module:spring-boot-mongodb:checkstyleTestpassed.Tested on the current main branch (
535d133b) with JDK 25. Docker-based integration tests were not run.