Fix TypeError in EnqueueRelatedIdsHandler when element was deleted before message consumption#431
Open
cancan101 wants to merge 1 commit into
Open
Conversation
EnqueueRelatedIdsMessage carries only an element ID. If the element is deleted between the dispatch of the message and its consumption by a messenger worker, ElementService::getElementByType() returns null and passing it to IndexQueueService::updateIndexQueue() throws a TypeError, sending the message to the failed transport where retries can never succeed. Skip processing in that case, mirroring the null handling of the other ID-based message handlers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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.



Changes in this pull request
EnqueueRelatedIdsMessagecarries only an element ID. If the element is deleted between the dispatch of the message (e.g. fromupdateIndexQueue(..., enqueueRelatedItemsAsync: true)on element save) and its consumption by a messenger worker,ElementService::getElementByType()returnsnull. Passing that toIndexQueueService::updateIndexQueue()throws:Since a
TypeErroris anError(and is raised at argument binding), thetry/catch (Exception)insideupdateIndexQueue()cannot catch it, so the message lands in the failed transport where retries can never succeed — the element is gone.This PR skips processing when the element no longer exists, and adds a unit test covering the regression. There is nothing left to enqueue related items for in that case; the deletion of the element itself is handled separately via the
DELETEqueue operation.Additional info
Observed in production on v2.5.2 under a save-then-delete race (transient objects from import jobs). The same guard already exists conceptually in other ID-based async flows where the element is re-loaded from an ID.
🤖 Generated with Claude Code