Fix TOCTOU ymir_triage_in_progress race#459
Open
antbob wants to merge 1 commit intopackit:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new utility function get_jira_labels to retrieve labels for a Jira issue and updates the triage agent to skip processing for issues that already possess terminal labels, effectively preventing redundant triage tasks. Feedback was provided regarding a performance optimization in the triage agent, specifically suggesting that JiraLabels.all_labels() be called once outside the list comprehension to avoid unnecessary repeated set constructions.
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.
The jira_issue_fetcher can push the same issue to triage_queue twice due to a TOCTOU race between the fetcher's dedup checks and the triage agent setting ymir_triage_in_progress. Since there's a single triage agent instance processing sequentially, a pre-flight label check after popping from the queue is sufficient to catch duplicates so that by the time the second copy is popped, the first triage has already completed and set a terminal label. This is a rare condition and should not normally happen but we did run into it in production.