-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ecosystem): Implement cross-system issue synchronization #9
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
Open
akshayutture-augment
wants to merge
1
commit into
ecosystem-sync-integration-before
Choose a base branch
from
ecosystem-sync-integration-after
base: ecosystem-sync-integration-before
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import asdict, dataclass | ||
| 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() | ||
|
|
||
| @classmethod | ||
| def from_integration(cls, integration: Integration | RpcIntegration) -> AssignmentSource: | ||
| return AssignmentSource( | ||
| source_name=integration.name, | ||
| integration_id=integration.id, | ||
| ) | ||
|
|
||
| def to_dict(self) -> dict[str, Any]: | ||
| return asdict(self) | ||
|
|
||
| @classmethod | ||
| def from_dict(cls, input_dict: dict[str, Any]) -> AssignmentSource | None: | ||
| try: | ||
| return cls(**input_dict) | ||
| except (ValueError, TypeError): | ||
| return None | ||
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
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
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
38 changes: 38 additions & 0 deletions
38
tests/sentry/integrations/services/test_assignment_source.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from typing import Any | ||
|
|
||
| from sentry.integrations.services.assignment_source import AssignmentSource | ||
| from sentry.testutils.cases import TestCase | ||
|
|
||
|
|
||
| class TestAssignmentSource(TestCase): | ||
| def test_from_dict_empty_array(self): | ||
| data: dict[str, Any] = {} | ||
| result = AssignmentSource.from_dict(data) | ||
| assert result is None | ||
|
|
||
| def test_from_dict_inalid_data(self): | ||
| data = { | ||
| "foo": "bar", | ||
| } | ||
|
|
||
| result = AssignmentSource.from_dict(data) | ||
| assert result is None | ||
|
|
||
| def test_from_dict_valid_data(self): | ||
| data = {"source_name": "foo-source", "integration_id": 123} | ||
|
|
||
| result = AssignmentSource.from_dict(data) | ||
| assert result is not None | ||
| assert result.source_name == "foo-source" | ||
| assert result.integration_id == 123 | ||
|
|
||
| def test_to_dict(self): | ||
| source = AssignmentSource( | ||
| source_name="foo-source", | ||
| integration_id=123, | ||
| ) | ||
|
|
||
| result = source.to_dict() | ||
| assert result.get("queued") is not None | ||
| assert result.get("source_name") == "foo-source" | ||
| assert result.get("integration_id") == 123 |
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.
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.
🧩 Analysis chain
Fix dataclass default for
queuedto avoid a shared timestamp; consider makingfrom_dictmore robustRight now
queued: datetime = timezone.now()is evaluated once at import, so everyAssignmentSourceinstance created without an explicitqueuedwill share the same timestamp. That’s almost certainly not what you want for a “queued” field and is what Ruff’s RUF009 is warning about. You can make this per-instance by using a default factory:Separately,
from_dictcurrently does a rawcls(**input_dict), which will returnNoneif any extra or malformed keys are present. If this struct might cross version boundaries, you may want to pre-filter to known keys ({"source_name", "integration_id", "queued"}) before constructing, so older or newer producers don’t break deserialization just because of an unexpected field.I'll verify the review comment by inspecting the file, checking usage patterns, and confirming the technical accuracy of the suggestions.Now let me verify the file exists and check the actual imports and usage patterns:Now let me check the actual file and verify implementation details:
<
🏁 Script executed:
Length of output: 1017
🏁 Script executed:
Length of output: 4932
🏁 Script executed:
Length of output: 936
Let me check the test file to understand the exact expectations for
from_dict:🏁 Script executed:
Length of output: 1140
🏁 Script executed:
Length of output: 477
Fix dataclass default for
queuedto use per-instance factoryThe
queued: datetime = timezone.now()default is evaluated once at module import, so everyAssignmentSourceinstance created without an explicitqueuedvalue shares the same timestamp. This is a semantic bug and is what Ruff's RUF009 warns about. Fix it by using a default factory:Separately,
from_dictcurrently rejects any dict with unexpected keys or missing required fields by catchingTypeErrorand returningNone. If this struct crosses version boundaries (e.g., older producers sending unknown fields), consider pre-filtering to known keys ({"source_name", "integration_id", "queued"}) before unpacking to improve forward/backward compatibility—though the current behavior is deliberate per the tests.📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.14.5)
18-18: Do not perform function call
timezone.nowin dataclass defaults(RUF009)
🤖 Prompt for AI Agents