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: ElectronBrowserContext::PartitionKey comparisons #41055

Merged
merged 2 commits into from Jan 23, 2024

Conversation

ckerr
Copy link
Member

@ckerr ckerr commented Jan 19, 2024

Description of Change

Use c++20 default comparisons to simplify + fix two bugs in PartitionKey sorting:

  1. The equality operator is broken. PartitionKey{"foo", false} is both equal to, and less than, PartitionKey{"foo", true}

  2. For some keys, the same session can be retrieved via both fromPath() and fromPartition(). This use case was discussed and removed from the original PR after code review said "always returning different sessions feels lower maintenance." The current behavior is a bug that comes from the comparison operators not checking the keys' types.

All reviews welcomed. CC @zcbenz as the 36728 reviewer who discussed the 'same session' use case

Checklist

Release Notes

Notes: Fixed session.fromPartition() key lookup bug.

Use c++20 default comparisons to simplify + fix PartitionKey sorting:

- The equality operator is broken. `PartitionKey{"foo", false}` is both
  equal, to and less than, `PartitionKey{"foo", true}`

- For some keys, the same session can be retrieved via both `fromPath()`
  and `fromPartition()`. This use case was discussed and removed from
  the original PR after code review said "always returning different
  sessions feels lower maintenance." The current behavior is a bug that
  comes from the comparison operators not checking the keys' types.

Xref: 3f1aea9#r1099745359

Xref: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-features.md#Default-comparisons-allowed
@ckerr ckerr added semver/patch backwards-compatible bug fixes target/27-x-y PR should also be added to the "27-x-y" branch. target/28-x-y PR should also be added to the "28-x-y" branch. target/29-x-y PR should also be added to the "29-x-y" branch. labels Jan 19, 2024
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 19, 2024
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jan 20, 2024
@ckerr ckerr requested a review from zcbenz January 22, 2024 20:45
@ckerr ckerr merged commit 1af9612 into main Jan 23, 2024
18 checks passed
@ckerr ckerr deleted the fix/browser-context-partition-key-comparisons branch January 23, 2024 15:41
Copy link

release-clerk bot commented Jan 23, 2024

Release Notes Persisted

Fixed session.fromPartition() key lookup bug.

@trop
Copy link
Contributor

trop bot commented Jan 23, 2024

I was unable to backport this PR to "27-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot added needs-manual-bp/27-x-y and removed target/27-x-y PR should also be added to the "27-x-y" branch. labels Jan 23, 2024
@trop
Copy link
Contributor

trop bot commented Jan 23, 2024

I have automatically backported this PR to "28-x-y", please check out #41083

@trop trop bot added in-flight/28-x-y and removed target/28-x-y PR should also be added to the "28-x-y" branch. labels Jan 23, 2024
@trop
Copy link
Contributor

trop bot commented Jan 23, 2024

I have automatically backported this PR to "29-x-y", please check out #41084

@trop trop bot added in-flight/29-x-y and removed target/29-x-y PR should also be added to the "29-x-y" branch. labels Jan 23, 2024
@trop trop bot added merged/28-x-y PR was merged to the "28-x-y" branch. merged/29-x-y PR was merged to the "29-x-y" branch. and removed in-flight/28-x-y in-flight/29-x-y labels Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/28-x-y PR was merged to the "28-x-y" branch. merged/29-x-y PR was merged to the "29-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants