Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Fix bug that was causing duplicate keys in sessions #1310

Merged
merged 3 commits into from
Apr 1, 2024

Conversation

lizkenyon
Copy link
Contributor

WHY are these changes introduced?

We were returning duplicate keys in the Session when using the new returnUserData flag, with the FromPropertyArray. I don't believe this should be causing any issues, because the key were also being added to the correct position in the object.

WHAT is this pull request doing?

  • Adds tests to ensure that the the associatedUserObject is created correctly, when using the returnUserData flag.

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have used yarn changeset to create a draft changelog entry (do NOT update the CHANGELOG.md file manually)
  • I have added/updated tests for this change
  • I have documented new APIs/updated the documentation for modified APIs (for public APIs)

@lizkenyon lizkenyon requested a review from a team as a code owner April 1, 2024 15:02
(associatedUserObj.associated_user.id = Number(value)),
];
associatedUserObj.associated_user.id = Number(value);
return [key, undefined];
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we need to filter these undefined values? Having all of this in the switch inside the map does make it a bit hard to follow. I wonder if we should change this last map call to just directly access all of the fields? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this function is very confusing which is part of the reason I missed this at first.

I agree with a bit of a refactor.

…rtyArray, when returnUserData = true

Refactor fromPropertyArray

Remove console

Cast to any
@lizkenyon lizkenyon force-pushed the liz/remove-duplicate-key-from-session branch from 2f6d120 to 96a0aab Compare April 1, 2024 17:18
We currently allow extra fields to be passed in
Boolean(value);
break;
}
case 'emailVerified':
if (returnUserData) {
sessionData.onlineAccessInfo.associated_user.email_verified =
sessionData.onlineAccessInfo!.associated_user.email_verified =
Boolean(value);
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good! One last question - can we replace setting the prototype of sessionData in line 137 with creating an actual Session instance? Not a blocker if we can't!

@lizkenyon lizkenyon merged commit 0c9e587 into main Apr 1, 2024
10 checks passed
@lizkenyon lizkenyon deleted the liz/remove-duplicate-key-from-session branch April 1, 2024 17:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants