Repository navigation
RUBY-3482 Disallow comma in authMechanismProperties connection string value - #3086
Merged
comandeo-mongo merged 1 commit intoJul 29, 2026
Merged
Conversation
… value Parse key-value pairs (authMechanismProperties, readPreferenceTags) using the first colon only, so a value may contain colons such as TOKEN_RESOURCE:mongodb://host. For authMechanismProperties, a comma-broken pair means the value contained a comma, which is not allowed in a connection string. Discard the whole option and warn instead of keeping a partial, misleading hash.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Ruby driver’s connection-string parsing to correctly handle colons inside key-value option values while ensuring authMechanismProperties does not accept comma-broken values, in line with the connection-string specification requirements described in RUBY-3482 / DRIVERS-2915.
Changes:
- Adjust
hash_extractorto split key/value pairs on the first colon only (split(':', 2)), allowing colons inside values. - Add
invalidate_on_error:behavior so malformed pairs inauthMechanismPropertiescause the entire option to be discarded (with a warning), rather than partially parsed. - Extend unified YAML fixtures and Ruby specs to cover colon-in-value parsing and the new comma/warning behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/mongo/uri/options_mapper.rb | Updates key-value parsing to allow colons in values and discard invalid authMechanismProperties as a whole. |
| lib/mongo/client.rb | Documents that comma-containing auth mechanism property values must be provided via :auth_mech_properties rather than the URI. |
| spec/mongo/uri/options_mapper_spec.rb | Adds/updates unit coverage for colon-in-value handling and whole-option invalidation behavior. |
| spec/spec_tests/data/connection_string/valid-options.yml | Adds a unified test case validating colon-in-value parsing for authMechanismProperties. |
| spec/spec_tests/data/connection_string/valid-warnings.yml | Adds a unified test case validating warnings when a comma breaks authMechanismProperties. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jamis
approved these changes
Jul 21, 2026
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.
Handles colons in connection-string key-value option values and disallows commas in authMechanismProperties values, per DRIVERS-2915 / connection-string spec.
Changes
Source:
lib/mongo/uri/options_mapper.rb—hash_extractorsplits each pair on the first colon only (split(':', 2)), so a value may contain colons (e.g.TOKEN_RESOURCE:mongodb://host). Newinvalidate_on_error:kwarg: forauthMechanismProperties, a comma-broken pair (a value that contained a comma) discards the whole option and logs a warning instead of keeping a partial hash.readPreferenceTagskeeps its prior per-pair skip behavior.lib/mongo/client.rb— document that a value containing a comma must be passed via the:auth_mech_propertiesoption, not the connection string.Tests:
spec/spec_tests/data/connection_string/valid-options.yml— colon-in-value case.spec/spec_tests/data/connection_string/valid-warnings.yml— comma-causes-warning case.spec/mongo/uri/options_mapper_spec.rb— updated to the new discard-whole-option behavior; added colon-in-value case.Fixtures are adapted for Ruby: the driver has no MONGODB-OIDC mechanism, and
client.rbdowncases auth mechanism property keys, so the OIDC mechanism is dropped and expected keys are lowercased.Test plan
bundle exec rspec spec/spec_tests/connection_string_spec.rb spec/spec_tests/uri_options_spec.rb spec/mongo/uri/options_mapper_spec.rb— 758 examples, 0 failuresbundle exec rubocopon all touched files — no offensesJira: https://jira.mongodb.org/browse/RUBY-3482