bridgev2/userlogin: copy the remote profile when filling bridge state#468
Closed
bridgev2/userlogin: copy the remote profile when filling bridge state#468
Conversation
Pointing into ul.RemoteProfile directly means that the RemoteProfile in the pending BridgeState will always point to the "latest" RemoteProfile, which leads the RemoteProfile comparison in ShouldDeduplicate to always think that the RemoteProfile hasn't changed. It's always going to dereference the same two pointers.
tulir
reviewed
Mar 7, 2026
| state.RemoteName = ul.RemoteName | ||
| state.RemoteProfile = &ul.RemoteProfile | ||
| profileCopy := ul.RemoteProfile | ||
| state.RemoteProfile = &profileCopy |
Member
There was a problem hiding this comment.
Might be better to just make BridgeState.RemoteProfile a non-pointer
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.
Here's the relevant line:
go/bridgev2/userlogin.go
Line 515 in 7836f35
By pointing into
ul.RemoteProfiledirectly, the "pending"BridgeStatewill always point to the "latest"RemoteProfile, which leads theRemoteProfilecomparison inShouldDeduplicateto always think that theRemoteProfilehasn't changed:go/bridgev2/status/bridgestate.go
Lines 208 to 213 in 7836f35
I think it's always going to dereference the same two pointers; i.e. it does
*ul.RemoteProfile == *ul.RemoteProfilewhich would always betrue.We can make a copy instead, which will do a shallow snapshot of sorts:
It wouldn't be resilient to in-place
AvatarFilemutations that don't take care to replace the entire value, but that seems okay?