-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
+125
−3
Conversation
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
nattsw
approved these changes
Aug 11, 2025
There was a problem hiding this 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
channel_1.add(autocomplete_user) | ||
end | ||
|
||
it "fails on subsequent autocomplete selection due to cache pollution" do |
There was a problem hiding this comment.
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
tyb-talks
added a commit
that referenced
this pull request
Aug 14, 2025
…ults (#34283) Related to #34208. Previously, missing name properties for a selected user search result would fail silently which made it difficult to tell if something had gone wrong with the user autocomplete. This PR adds some error handling to make it more obvious that an error has occurred. I've opted for using `toasts` here since it's less intrusive compared to the `dialog` modal. https://github.com/user-attachments/assets/92f585d8-95bf-4c5b-a08a-698c1a527b79
yuriyaran
pushed a commit
that referenced
this pull request
Aug 21, 2025
The current chat autocomplete pipeline can mutate the user object selected for autocomplete here: https://github.com/discourse/discourse/blob/071e82140cf375e2875b87d1664ae596c19320dd/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs#L485 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: https://github.com/discourse/discourse/blob/216df43502e25fcb9a228bfc09f90548712d7f49/app/assets/javascripts/discourse/app/services/store.js#L426-L435 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.
yuriyaran
pushed a commit
that referenced
this pull request
Aug 21, 2025
…ults (#34283) Related to #34208. Previously, missing name properties for a selected user search result would fail silently which made it difficult to tell if something had gone wrong with the user autocomplete. This PR adds some error handling to make it more obvious that an error has occurred. I've opted for using `toasts` here since it's less intrusive compared to the `dialog` modal. https://github.com/user-attachments/assets/92f585d8-95bf-4c5b-a08a-698c1a527b79
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.
The current chat autocomplete pipeline can mutate the user object selected for autocomplete here:
discourse/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs
Line 485 in 071e821
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:
discourse/app/assets/javascripts/discourse/app/services/store.js
Lines 426 to 435 in 216df43
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.