Skip to content

FIX: user autocomplete search cache pollution #34208

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

Merged
merged 3 commits into from
Aug 11, 2025

Conversation

tyb-talks
Copy link
Contributor

@tyb-talks tyb-talks commented Aug 11, 2025

The current chat autocomplete pipeline can mutate the user object selected for autocomplete here:

Specifically this occurs when we attempt to create a record in the store service where it already exists, and the logic for fetching the right record there deletes some properties from the input object:

untrack(() => {
// Only update properties whose values actually changed to optimize rerenders
// If a property value is unchanged, remove it from the update list
updatedProperties &&
Object.keys(updatedProperties).forEach((key) => {
if (existing[key] === updatedProperties[key]) {
delete updatedProperties[key];
}
});
});

This mutates the object that is eventually used to replace the search term (and therefore causes an error as it is now missing all its properties except for id). This also pollutes the upstream cache in the userSearch JS module.

This PR fixes both issues by cloning the user objects before they get passed into the processing functions.

@github-actions github-actions bot added the chat PRs which include a change to Chat plugin label Aug 11, 2025
@tyb-talks tyb-talks marked this pull request as ready for review August 11, 2025 03:19
Copy link
Contributor

@nattsw nattsw left a comment

Choose a reason for hiding this comment

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

Cool, thanks for the desc

@tyb-talks tyb-talks merged commit a71eb41 into main Aug 11, 2025
16 checks passed
@tyb-talks tyb-talks deleted the fix-autocomplete-search-cache-pollution branch August 11, 2025 05:14
channel_1.add(autocomplete_user)
end

it "fails on subsequent autocomplete selection due to cache pollution" do
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be?

does not fail on subsequent autocomplete selection due to cache pollution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat PRs which include a change to Chat plugin
Development

Successfully merging this pull request may close these issues.

3 participants