You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've reviewed the PR implementing cross-system issue synchronization to prevent sync cycles. Overall, this is a solid implementation with good test coverage. Below are my findings:
Summary
This PR introduces an AssignmentSource tracking mechanism to prevent infinite sync loops when assignments propagate between Sentry and external integrations (like Jira, GitHub, etc.). The solution correctly blocks outbound syncs when the assignment originated from the same integration, preventing cycles.
@dataclass(frozen=True)classAssignmentSource:
source_name: strintegration_id: intqueued: datetime=timezone.now() # ⚠️ Problem here
Using timezone.now() as a default argument is evaluated once at class definition time, not at instantiation time. This means all AssignmentSource instances will share the same timestamp if the default is used.
The assignment_source parameter is passed to sync_assignee_outbound() method but the type signature in the abstract method definition doesn't include it as a kwarg.
Good separation of concerns: The AssignmentSource service is cleanly separated into its own module
Proper cycle prevention: The logic in should_sync() (lines 382-394 of issues.py) correctly checks if the source integration matches the target to prevent loops
Comprehensive test coverage: The new test test_assignee_sync_outbound_assign_with_matching_source_integration specifically validates the cycle prevention
Consistent propagation: AssignmentSource is properly threaded through assign(), deassign(), and sync_group_assignee_outbound() functions
Safe deserialization: from_dict() properly handles errors and returns None for invalid data
Frozen dataclass: Using frozen=True prevents accidental mutation
Questions & Suggestions
1. Queued Timestamp Usage 🤔
The queued field in AssignmentSource is tracked but never used in the code. Is this for future use (e.g., debugging, rate limiting, or staleness checks)? Consider:
Adding a docstring explaining its purpose
Or removing it if not needed yet (YAGNI principle)
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
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.
Test 7nn---nReplicated from ai-code-review-evaluation/sentry-greptile#7