-
Notifications
You must be signed in to change notification settings - Fork 0
Automated Test: ecosystem-sync-integration-after #230
Automated Test: ecosystem-sync-integration-after #230
Conversation
📝 WalkthroughWalkthroughThe changes introduce Changes
Sequence DiagramsequenceDiagram
participant ExtSys as External System
participant Sentry as Sentry (Inbound)
participant GAM as GroupAssignee Mgr
participant Sync as Sync Utilities
participant Task as Task Queue
participant ExtInteg as External Integration
ExtSys->>Sentry: Sync assignee change
Sentry->>GAM: assign(group, user, assignment_source=ext_integration)
GAM->>Sync: sync_group_assignee_outbound(group, user, assignment_source)
Sync->>Task: Queue task with assignment_source_dict
Task->>ExtInteg: should_sync("assignee", sync_source=assignment_source)
alt Cycle Prevention Triggered
ExtInteg-->>Task: False (source matches this integration)
Task-->>Sync: Skip outbound sync
else Normal Flow
ExtInteg-->>Task: True (different integration)
Task->>ExtInteg: sync_assignee_outbound(external_issue, user, assignment_source)
ExtInteg-->>ExtSys: Sync confirmation
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/sentry/integrations/services/assignment_source.py`:
- Line 18: The queued default is set by calling timezone.now() at
class-definition time, causing all AssignmentSource instances to share a single
timestamp; change the queued field to use a default factory so it is evaluated
per-instance (e.g., use dataclasses.field(default_factory=timezone.now) or the
equivalent factory pattern in the class) and import field if necessary; update
the AssignmentSource definition to reference field(default_factory=timezone.now)
for the queued attribute.
🧹 Nitpick comments (2)
tests/sentry/integrations/services/test_assignment_source.py (2)
8-8: Minor: Test method name is misleading.The method tests an empty
dict, not an empty array. Consider renaming totest_from_dict_empty_dictfor clarity.
13-13: Typo in test method name: "inalid" → "invalid".✏️ Proposed fix
- def test_from_dict_inalid_data(self): + def test_from_dict_invalid_data(self):
| class AssignmentSource: | ||
| source_name: str | ||
| integration_id: int | ||
| queued: datetime = timezone.now() |
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.
timezone.now() is evaluated once at class definition time, not per instance.
The default value timezone.now() is called when the module loads, so every AssignmentSource instance without an explicit queued argument will share the same stale timestamp. Use field(default_factory=...) instead.
🐛 Proposed fix
-from dataclasses import asdict, dataclass
+from dataclasses import asdict, dataclass, field
from datetime import datetime
from typing import TYPE_CHECKING, Any
from django.utils import timezone
if TYPE_CHECKING:
from sentry.integrations.models import Integration
from sentry.integrations.services.integration import RpcIntegration
`@dataclass`(frozen=True)
class AssignmentSource:
source_name: str
integration_id: int
- queued: datetime = timezone.now()
+ queued: datetime = field(default_factory=timezone.now)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| queued: datetime = timezone.now() | |
| from dataclasses import asdict, dataclass, field | |
| from datetime import datetime | |
| from typing import TYPE_CHECKING, Any | |
| from django.utils import timezone | |
| if TYPE_CHECKING: | |
| from sentry.integrations.models import Integration | |
| from sentry.integrations.services.integration import RpcIntegration | |
| `@dataclass`(frozen=True) | |
| class AssignmentSource: | |
| source_name: str | |
| integration_id: int | |
| queued: datetime = field(default_factory=timezone.now) |
🧰 Tools
🪛 Ruff (0.14.14)
[warning] 18-18: Do not perform function call timezone.now in dataclass defaults
(RUF009)
🤖 Prompt for AI Agents
In `@src/sentry/integrations/services/assignment_source.py` at line 18, The queued
default is set by calling timezone.now() at class-definition time, causing all
AssignmentSource instances to share a single timestamp; change the queued field
to use a default factory so it is evaluated per-instance (e.g., use
dataclasses.field(default_factory=timezone.now) or the equivalent factory
pattern in the class) and import field if necessary; update the AssignmentSource
definition to reference field(default_factory=timezone.now) for the queued
attribute.
This pull request was automatically created by
@coderabbitai/e2e-reviewer.Batch created pull request.
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.