-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ecosystem): Breaks issue sync cycles #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
0cf53ea
f665d92
94578b8
6eb81dc
40cfb76
cb2b417
cc67c4c
9501091
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
Comment on lines
+27
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
python - <<'PY'
from dataclasses import dataclass
`@dataclass`(frozen=True)
class AssignmentSource:
source_name: str
integration_id: int
bad = AssignmentSource(**{"source_name": "jira", "integration_id": "123"})
print("runtime type:", type(bad.integration_id).__name__)
print("matches int 123:", bad.integration_id == 123)
PYRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 145 🏁 Script executed: #!/bin/bash
set -euo pipefail
# 1) Read the actual AssignmentSource definition + from_dict implementation
FILE="src/sentry/integrations/services/assignment_source.py"
if [ -f "$FILE" ]; then
echo "=== $FILE ==="
nl -ba "$FILE" | sed -n '1,200p'
else
echo "Missing file: $FILE" >&2
exit 1
fi
# 2) Find where IssueSyncIntegration.should_sync compares integration_id
# (Search for IssueSyncIntegration and should_sync)
echo "=== Search IssueSyncIntegration ==="
rg -n "class IssueSyncIntegration|def should_sync" -S src/sentry || true
# 3) Find comparisons involving integration_id in sync-related code
echo "=== Search integration_id comparisons ==="
rg -n "integration_id" -S src/sentry/integrations || trueRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 227 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="src/sentry/integrations/services/assignment_source.py"
echo "=== $FILE (first 200 lines with numbers) ==="
if [ -f "$FILE" ]; then
cat -n "$FILE" | sed -n '1,200p'
else
echo "Missing file: $FILE" >&2
exit 1
fi
echo "=== rg: class IssueSyncIntegration / def should_sync ==="
rg -n "class IssueSyncIntegration|def should_sync" -S src/sentry || true
echo "=== rg: integration_id comparisons in integrations/services ==="
rg -n "integration_id" -S src/sentry/integrations/services || true
echo "=== rg: integration_id comparisons in integrations ==="
rg -n "integration_id" -S src/sentry/integrations | head -n 200 || trueRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 35789 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== rg: AssignmentSource.from_dict usage ==="
rg -n "AssignmentSource\.from_dict|\.from_dict\(" -S src/sentry/integrations/mixins/issues.py src/sentry || true
echo "=== show IssueSyncIntegration.should_sync implementation ==="
# Print the relevant region around should_sync and any uses of sync_source/integration_id comparisons
rg -n "class IssueSyncIntegration|def should_sync" -n src/sentry/integrations/mixins/issues.py
sed -n '330,470p' src/sentry/integrations/mixins/issues.py
echo "=== also inspect earlier should_sync (mixin base) ==="
sed -n '1,120p' src/sentry/integrations/mixins/issues.pyRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 11356 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Show sync_assignee_outbound.py around AssignmentSource.from_dict ==="
sed -n '1,140p' src/sentry/integrations/tasks/sync_assignee_outbound.py
echo "=== rg assignment_source_dict ==="
rg -n "assignment_source_dict" -S src/sentry/integrations || true
echo "=== rg: should_sync( and sync_source= ==="
rg -n "should_sync\\(|sync_source=" -S src/sentry/integrations/mixins/issues.py src/sentry/integrations || true
echo "=== rg: from_dict(assignment_source" # narrow search
rg -n "AssignmentSource\\.from_dict\\(" -S src/sentry/integrations || trueRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 4775 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Show src/sentry/integrations/utils/sync.py around assignment_source_dict ==="
sed -n '1,220p' src/sentry/integrations/utils/sync.py
echo "=== Search other task usage of AssignmentSource.from_dict(assignment_source_dict) ==="
rg -n "AssignmentSource\\.from_dict\\(assignment_source_dict\\)" -S src/sentry/integrations/tasks || true
echo "=== Inspect sync_status_outbound task for AssignmentSource.from_dict usage ==="
sed -n '1,140p' src/sentry/integrations/tasks/sync_status_outbound.pyRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 7529 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== rg: AssignmentSource.from_dict( ==="
rg -n "AssignmentSource\.from_dict\(" -S src/sentry || true
echo "=== rg: AssignmentSource\.to_dict\(" # where dict payloads are created
rg -n "AssignmentSource\.to_dict\(" -S src/sentry || true
echo "=== rg: assignment_source_dict building ==="
rg -n "assignment_source_dict" -S src/sentry/integrations || true
echo "=== rg: from_integration( ==="
rg -n "AssignmentSource\.from_integration" -S src/sentry/integrations || trueRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 1038 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== Search Celery/task serializer configuration ==="
rg -n "task_serializer|accept_content|serializer|json_serializer|pickle|dumps\\(|loads\\(" -S src/sentry | head -n 200
echo "=== Search for custom serializer that might stringify ints/datetimes ==="
rg -n "orjson|ujson|msgpack|pickle|kombu|celery" -S src/sentry | head -n 200Repository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 40162 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== rg Celery TASK_SERIALIZER / ACCEPT_CONTENT ==="
rg -n "CELERY_(TASK_SERIALIZER|ACCEPT_CONTENT|RESULT_SERIALIZER|SERIALIZER)|task_serializer|accept_content" -S . | head -n 200 || true
echo "=== rg sentry/celery config ==="
rg -n "from celery|Celery\\(" -S src/sentry/celery src/sentry | head -n 200 || true
echo "=== list likely settings files ==="
fd -t f -e py -e toml -e ini -e yml -e yaml -e cfg -a "settings*.py" . 2>/dev/null || trueRepository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407 Length of output: 4189 Downgrade severity: current code path doesn’t stringify
🤖 Prompt for AI Agents |
||
| 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 |
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
🏁 Script executed:
Repository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407
Length of output: 272
🏁 Script executed:
Repository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407
Length of output: 147
🏁 Script executed:
Repository: test-code-tool/sentry__sentry__coderabbit__PR77754__20260407
Length of output: 1260
Use
field(default_factory=timezone.now)forAssignmentSource.queued.In
src/sentry/integrations/services/assignment_source.py(around lines 14-18),queued: datetime = timezone.now()is evaluated once at class definition time, so all instances created without an explicitqueuedshare the same timestamp. Usedefault_factoryinstead.Suggested fix
🧰 Tools
🪛 Ruff (0.15.15)
[warning] 18-18: Do not perform function call
timezone.nowin dataclass defaults(RUF009)
🤖 Prompt for AI Agents