Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NODE-3920)!: validate options are not repeated in connection string #3788

Merged
merged 3 commits into from
Aug 1, 2023

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Jul 28, 2023

Description

What is changing?

  • Add validation for repeated options that aren't readPreferenceTags
  • Fix bug with empty readPreferenceTags
Is there new documentation needed for these changes?

None

What is the motivation for this change?

See highlights

Release Highlight

Repeated options in connection string are no longer allowed

In order to avoid accidental misconfiguration the driver will no longer prioritize the first instance of an option provided on the URI. Instead repeated options that are not permitted to be repeated will throw an error. This is to that connection strings that contain options like tls=true&tls=false are no longer ambiguous.

Empty readPreferenceTags in connection string fixed

The following connection string will now produce the following readPreferenceTags:

"mongodb://host?readPreferenceTags=region:ny&readPreferenceTags=rack:r1&readPreferenceTags=";
// client.options.readPreference.tags
[{ region: 'ny' }, { rack: 'r1' }, { }];

The empty readPreferenceTags allows drivers to still select a server if the leading tag conditions are not met.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken marked this pull request as ready for review July 28, 2023 21:18
@durran durran self-assigned this Jul 31, 2023
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 31, 2023
src/connection_string.ts Outdated Show resolved Hide resolved
test/unit/connection_string.spec.test.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken requested a review from durran July 31, 2023 14:00
@durran durran added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Aug 1, 2023
@durran durran merged commit 11631a2 into main Aug 1, 2023
@durran durran deleted the NODE-3920-non-list-options branch August 1, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants