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

fix(NODE-3813): unexpected type conversion of read preference tags #3138

Merged
merged 14 commits into from Feb 11, 2022

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Feb 8, 2022

Description

What is changing?

This PR does two things:

  • fixes options parsing for arrays of options.
  • refactors how we parse key-value pairs of options for a particular option. In particular, it removes logic from parsing readPreference that was converting string values to native JS types, causing spec tests to fail
Is there new documentation needed for these changes?

No.

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>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@baileympearson baileympearson marked this pull request as ready for review February 9, 2022 14:50
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Feb 9, 2022
@durran
Copy link
Member

durran commented Feb 9, 2022

CSFLE failures unrelated and fixed in #3070

src/connection_string.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to either unskip or update the TODO tagged to this ticket in uri_options.spec.test

@baileympearson baileympearson force-pushed the NODE-3813-parse-readpreference-tags-correctly branch from 6545f24 to 991c0eb Compare February 9, 2022 20:01
durran
durran previously approved these changes Feb 10, 2022
@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 Feb 10, 2022
src/connection_string.ts Outdated Show resolved Hide resolved
src/connection_string.ts Outdated Show resolved Hide resolved
src/connection_string.ts Outdated Show resolved Hide resolved
src/connection_string.ts Outdated Show resolved Hide resolved
src/connection_string.ts Outdated Show resolved Hide resolved
src/connection_string.ts Outdated Show resolved Hide resolved
@baileympearson baileympearson force-pushed the NODE-3813-parse-readpreference-tags-correctly branch from c93902e to 98b1448 Compare February 11, 2022 18:20
nbbeeken
nbbeeken previously approved these changes Feb 11, 2022
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

for (const [key, _value] of entriesFromString(value)) {
if (validKeys.includes(key)) {
if (key === 'CANONICALIZE_HOST_NAME') {
mechanismProperties[key] = getBoolean(key, _value);
Copy link
Contributor

@dariakp dariakp Feb 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that this is probably going to conflict with Durran's PR to expand the CANONICALIZE_HOST_NAME options (#3131)

@@ -631,7 +634,28 @@ export const OPTIONS = {
target: 'credentials',
transform({ options, values: [value] }): MongoCredentials {
if (typeof value === 'string') {
value = toRecord(value);
const validKeys = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to intentionally silently ignore invalid keys here? Does this actually produce the same behavior as before?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This array might be unnecessary, the idea was to only translate the type of the keys we know about and leave whatever remains as is (strings). I spoke generally about the options, so that might be where the inspiration came from but I think CANONICALIZE_HOST_NAME, and gssapiCannoncializeHostname (which we need to add here, whoops!) are the only ones that need translating to boolean. the rest can remain as strings

@nbbeeken nbbeeken changed the title fix(NODE-3813): fix parsing of read preference tags fix(NODE-3813): unexpected type conversion of read preference tags Feb 11, 2022
@nbbeeken nbbeeken merged commit 3e7b894 into main Feb 11, 2022
@nbbeeken nbbeeken deleted the NODE-3813-parse-readpreference-tags-correctly branch February 11, 2022 23:24
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
4 participants