Repository navigation
[FLINK-40957][connect/mongodb] Fix MongoDB credential encoding for spaces - #4568
LuanaMihailescu wants to merge 6 commits into
Conversation
04b71f2 to
149b79e
Compare
|
Hi @leonardBang This PR fixes the credential encoding issue described in FLINK-40957 and includes a test case for the reported behavior. Could you please review it when you have time? Thanks! |
|
Hi @lvyanquan This PR fixes the credential encoding issue described in FLINK-40957 and includes a test case for the reported behavior. Could you please review it when you have time? Thanks! |
sd4324530
left a comment
There was a problem hiding this comment.
Hi, I left some comments. Currently, CI hasn't passed. You can refer to the format of other files in the project and make corresponding modifications. It would be even better if you could successfully compile locally first.
yuxiqian
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Just left some comments.
|
CI is still failing, please run |
…in buildConnectionString
Per review feedback, revert MongoDBEnvelope#encodeValue() to its original,
generic percent-encoding behavior, since it is not specific to MongoDB
credentials and other callers could be affected by changing it.
Move the space ('+' -> '%20') correction into a new private
MongoUtils#encodeCredential() helper, applied only to username/password
when building the connection string in buildConnectionString(). Replace
MongoDBEnvelopeTest (which tested the reverted behavior) with MongoUtilsTest,
covering buildConnectionString directly.
…taining spaces Add end-to-end tests to MongoDBParallelSourceITCase verifying that the MongoDB CDC source authenticates and reads data successfully when the username and/or password contain spaces, per review feedback.
|
Thanks for the feedback. I've updated the implementation based on the review comments, added unit and integration tests, and addressed the Spotless formatting issues. Could someone please re-run the CI checks when possible? Thanks! |
Jiabao-Sun
left a comment
There was a problem hiding this comment.
Thanks @LuanaMihailescu for this fix.
Could you help verify if other special characters like ~ and * would have the same problem?
|
Hi @Jiabao-Sun, I've checked |
What is the purpose of this pull request?
This PR fixes the encoding of MongoDB credentials containing spaces.
MongoDBEnvelope.encodeValue()currently relies onURLEncoder, which encodes spaces as+according toapplication/x-www-form-urlencodedsemantics. However, MongoDB connection URIs expect spaces to be percent-encoded as%20.This change ensures that spaces are encoded as
%20, preventing authentication issues when usernames or passwords contain spaces.JIRA: FLINK-40957
Brief change log
MongoDBEnvelope.encodeValue()to encode spaces as%20instead of+Verifying this change
This change added tests and can be verified as follows:
MongoDBEnvelopeTestMongoDBEnvelope.encodeValue("my pass")returnedmy+passbefore the fixMongoDBEnvelope.encodeValue("my pass")returnsmy%20passafter the fixDocumentation
Was generative AI tooling used to co-author this PR?