crbench//

← all cases

GitLab integration search returns full project paths

Tier 2 easy python · cross-file · real merged PR from getsentry/sentry #107216

Ground-truth defects

d1 · correctness · medium
The GitLab integration switches the project identifier to `path_with_namespace` (an `org/repo` string containing a slash) but then interpolates it into GitLab API request paths without URL-encoding it. The unescaped `/` makes the formatted path resolve to the wrong API route, breaking blame / issue calls for any project. The fix URL-safe-quotes the project id at the call sites.
d2 · correctness · medium
The new `sync_status_forward` handler validates only truthiness up front, then unconditionally deletes every existing IntegrationExternalProject row before looping to create the replacements, raising per item on an invalid status. There is no surrounding transaction, and the endpoint converts the error to a 400, so a request rejected part-way has already destroyed the organization's previously configured status mappings.

The change under review

diff (truncated — full diff)
diff --git a/src/sentry/integrations/gitlab/client.py b/src/sentry/integrations/gitlab/client.py
index b35e79446d714e..39653aa11c2d86 100644
--- a/src/sentry/integrations/gitlab/client.py
+++ b/src/sentry/integrations/gitlab/client.py
@@ -467,7 +467,7 @@ def search_project_issues(self, project_id, query, iids=None):
 
         See https://docs.gitlab.com/ee/api/issues.html#list-project-issues
         """
-        path = GitLabApiClientPath.project_issues.format(project=project_id)
+        path = GitLabApiClientPath.project_issues.format(project=quote(str(project_id), safe=""))
 
         return self.get(path, params={"scope": "all", "search": query, "iids": iids})
 
diff --git a/src/sentry/integrations/gitlab/integration.py b/src/sentry/integrations/gitlab/integration.py
index cded5f32e53141..38f94c724db11e 100644
--- a/src/sentry/integrations/gitlab/integration.py
+++ b/src/sentry/integrations/gitlab/integration.py
@@ -6,6 +6,7 @@
 from urllib.parse import urlparse
 
 from django.http.request import HttpRequest
+from django.urls import reverse
 from django.utils.translation import gettext_lazy as _
 from rest_framework.fields import BooleanField, CharField, URLField
 
@@ -21,10 +22,12 @@
     IntegrationProvider,
 )
 from sentry.integrations.gitlab.constants import GITLAB_WEBHOOK_VERSION, GITLAB_WEBHOOK_VERSION_KEY
-from sentry.integrations.gitlab.tasks import update_all_project_webhooks
+from sentry.integrations.gitlab.types import GitLabIssueStatus
+from sentry.integrations.models.integration_external_project import IntegrationExternalProject
 from sentry.integrations.pipeline import IntegrationPipeline
 from sentry.integrations.referrer_ids import GITLAB_PR_BOT_REFERRER
 from sentry.integrations.services.integration import integration_service
+from sentry.integrations.services.repository import repository_service
 from sentry.integrations.services.repository.model import RpcRepository
 from sentry.integrations.source_code_management.commit_context import (
     CommitContextIntegration,
@@ -47,6 +50,7 @@
     ApiForbiddenError,
     ApiUnauthorized,
     IntegrationConfigurationError,
+    IntegrationError,
     IntegrationProviderError,
 )
 from sentry.snuba.referrer import Referrer
@@ -291,6 +295,54 @@ def get_organization_config(self) -> list[dict[str, Any]]:
 
         has_issue_sync = features.has("organizations:integrations-issue-sync", organization)
 
+        # Add outbound status sync configuration if feature flag is enabled
+        if self.check_feature_flag():
+            # Get currently configured external projects to display their labels
+            current_project_items = []
+            if self.org_integration:
+                external_projects = IntegrationExternalProject.objects.filter(
+                    organization_integration_id=self.org_integration.id
+                )
+
+                if external_projects.exists():
+                    current_project_items = [
+                        {"value": project.external_id, "label": project.name}
+                        for project in external_projects
+                    ]
+
+            config.insert(
+                0,
+                {
+                    "name": self.outbound_status_key,
+                    "type": "choice_mapper",
+                    "label": _("Sync Sentry Status to GitLab"),
+                    "help": _(
+                        "When a Sentry issue changes status, change the status of the linked ticket in GitLab."
+                    ),
+                    "addButtonText": _("Add GitLab Project"),
+                    "addDropdown": {
+                        "emptyMessage": _("All projects configured"),
+                        "noResultsMessage": _("Could not find GitLab project"),
+                        "items": current_project_items,
+                        "url": reverse(
+                            "sentry-extensions-gitlab-search",
+                            args=[organization.slug, self.model.id],
+                        ),
+                        "searchField": "project",
+                    },
+                    "mappedSelectors": {
+                        "on_resolve": {"choices": GitLabIssueStatus.get_choices()},
+                        "on_unresolve": {"choices": GitLabIssueStatus.get_choices()},
+                    },
+                    "columnLabels": {
+                        "on_resolve": _("When resolved"),
+                        "on_unresolve": _("When unresolved"),
+                    },
+                    "mappedColumnLabel": _("GitLab Project"),
+                    "formatMessageValue": False,
+                },
+            )
+
         if not has_issue_sync:
             for field in config:
                 field["disabled"] = True
@@ -306,6 +358,43 @@ def update_organization_config(self, data: MutableMapping[str, Any]) -> None:
 
         config = self.org_integration.config
 
+        # Handle status sync configuration
+        if "sync_status_forward" in data:
+            project_mappings = data.pop("sync_status_forward")
+
+            # Validate that all mappings have both statuses
+            if any(
+                not mapping.get("on_unresolve") or not mapping.get("on_resolve")
+                for mapping in project_mappings.values()
+            ):
+                raise IntegrationError("Resolve and unresolve status are required.")
+
+            data["sync_status_forward"] = bool(project_mappings)
+
+            IntegrationExternalProject.objects.filter(
+                organization_integration_id=self.org_integration.id
+            ).delete()
+
+            for project_path, statuses in project_mappings.items():
+                # Validate status values
+                valid_statuses = {GitLabIssueStatus.OPENED.value, GitLabIssueStatus.CLOSED.value}
+                if statuses["on_resolve"] not in valid_statuses:
+                    raise IntegrationError(
+                        f"Invalid resolve status: {statuses['on_resolve']}. Must be 'opened' or 'closed'."
+                    )
+                if statuses["on_unresolve"] not in valid_statuses:
+                    raise IntegrationError(
+                        f"Invalid unresolve status: {statuses['on_unresolve']}. Must be 'opened' or 'closed'."
+                    )
+
+                IntegrationExternalProject.objects.create(
+                    organization_integration_id=self.org_integration.id,
+                    external_id=project_path,
+                    name=project_path,
+                    resolved_status=statuses["on_resolve"],
+                    unresolved_status=statuses["on_unresolve"],
+                )
+
         # Check webhook version BEFORE updating config to determine if migration is needed
         current_webhook_version = config.get(GITLAB_WEBHOOK_VERSION_KEY, 0)
 
@@ -318,11 +407,9 @@ def update_organization_config(self, data: MutableMapping[str, Any]) -> None:
         if org_integration is not None:
             self.org_integration = org_integration
 
-        # Only update webhooks if:
-        # 1. A sync setting was enabled, AND
-        # 2. The webhook version is outdated
+        # Only update webhooks if the webhook version is outdated
         if current_webhook_version < GITLAB_WEBHOOK_VERSION:
-            update_all_project_webhooks.delay(
+            repository_service.schedule_update_gitlab_project_webhooks(
                 integration_id=self.model.id,
                 organization_id=self.organization_id,
             )
diff --git a/src/sentry/integrations/gitlab/issue_sync.py b/src/sentry/integrations/gitlab/issue_sync.py
index 6012b00ff16357..2ffb5f14770737 100644
--- a/src/sentry/integrations/gitlab/issue_sync.py
+++ b/src/sentry/integrations/gitlab/issue_sync.py
@@ -6,11 +6,12 @@
 from urllib.parse import quote
 
 from sentry import features
-from sentry.integrations.gitlab.types import GitLabIssueAction
+from sentry.integrations.gitlab.types import GitLabIssueAction, GitLabIssueStatus
 from sentry.integrations.mixins.issues import IssueSyncIntegration, ResolveSyncAction
 from sentry.integrations.models.external_actor import ExternalActor
 from sentry.integrations.models.external_issue import ExternalIssue
 from sentry.integrations.models.integration_external_project import IntegrationExternalProject
+from sentry.integrations.services.integration import integration_service
 from sentry.integrations.types import EXTERNAL_PROVIDERS_REVERSE, ExternalProviderEnum
 from sentry.shared_integrations.exceptions import ApiError
 from sentry.users.services.user.model import RpcUser
@@ -24,6 +25,7 @@ class GitlabIssueSyncSpec(IssueSyncIntegration):
     outbound_assignee_key = "sync_forward_assignment"
     inbound_assignee_key = "sync_reverse_assignment"
     inbound_status_key = "sync_status_reverse"
+    outbound_status_key = "sync_status_forward"
     resolution_strategy_key = "resolution_strategy"
 
     def check_feature_flag(self) -> bool:
@@ -165,7 +167,93 @@ def sync_status_outbound(
         Propagate a sentry issue's status to a linked GitLab issue's status.
         For GitLab, we only support opened/closed states.
         """
-        raise NotImplementedError
+
+        client = self.get_client()
+        project_path, issue_iid = self.split_external_issue_key(external_issue.key)
+
+        if not project_path or not issue_iid:
+            logger.warning(
+                "status-outbound.invalid-key",
+                extra={
+                    "external_issue_key": external_issue.key,
+                    "provider": self.model.provider,
+                },
+            )
+            return
+
+        # Get the project mapping to determine what status to use
+        external_project = integration_service.get_integration_external_project(
+            organization_id=external_issue.organization_id,
+            integration_id=external_issue.integration_id,
+            external_id=project_path,
+        )
+
+        log_context = {
+            "provider": self.model.provider,
+            "integration_id": external_issue.integration_id,
+            "is_resolved": is_resolved,
+            "issue_key": external_issue.key,
+            "project_path": project_path,
+        }
+
+        if not external_project:
+            logger.info("external-project-not-found", extra=log_context)
+            return
+
+        desired_state = (
+            external_project.resolved_status if is_resolved else external_project.unresolved_status
+        )
+
+        # Fetch current GitLab issue state
+        try:
+            # URL-encode project_path since it's a path_with_namespace
+            encoded_project_path = quote(project_path, safe="")
+            issue_data = client.get_issue(encoded_project_path, issue_iid)
+        except ApiError as e:
+            self.raise_error(e)
+
+        current_state = issue_data.get("state")
+
+        # Don't update if it's already in the desired state
+        if current_state == desired_state:
+            logger.info(
+                "sync_status_outbound.unchanged",
+                extra={
+                    **log_context,
+                    "current_state": current_state,
+                    "desired_state": desired_state,
+                },
+            )
+            return
+
+        # Determine state_event parameter for GitLab API
+        # GitLab uses "close" to transition to closed, "reopen" to transition to opened
+        if desired_state == GitLabIssueStatus.CLOSED.value:
+            state_event = GitLabIssueAction.CLOSE.value
+        elif desired_state == GitLabIssueStatus.OPENED.value:
+            state_event = GitLabIssueAction.REOPEN.value
+        else:
+            logger.warning(
+                "sync_status_outbound.invalid-desired-state",
+                extra={**log_context, "desired_state": desired_state},
+            )
+            return
+
+        # Update the issue state
+        try:
+            encoded_project_path = quote(project_path, safe="")
+            client.update_issue_status(encoded_project_path, issue_iid, state_event)
+            logger.info(
+                "sync_status_outbound.success",
+                extra={
+                    **log_context,
+                    "old_state": current_state,
+                    "new_state": desired_state,
+                    "state_event": state_event,
+                },
+            )
+        except ApiError as e:
+            self.raise_error(e)
 
     def get_resolve_sync_action(self, data: Mapping[str, Any]) -> ResolveSyncAction:
         """
diff --git a/src/sentry/integrations/gitlab/search.py b/src/sentry/integrations/gitlab/search.py
index 597b70bdf1b8f6..56dabf0540426c 100644
--- a/src/sentry/integrations/gitlab/search.py
+++ b/src/sentry/integrations/gitlab/search.py
@@ -77,7 +77,10 @@ def handle_search_repositories(
                 return Response({"detail": str(e)}, status=400)
             return Response(
                 [
-                    {"label": project["name_with_namespace"], "value": str(project["id"])}
+                    {
+                        "label": project["name_with_namespace"],
+                        "value": project["path_with_namespace"],
+                    }
                     for project in response
                 ]
             )
diff --git a/src/sentry/integrations/gitlab/types.py b/src/sentry/integrations/gitlab/types.py
index 34935f78d6972a..668e14f0559812 100644
--- a/src/sentry/integrations/gitlab/types.py
+++ b/src/sentry/integrations/gitlab/types.py
@@ -10,3 +10,13 @@ class GitLabIssueAction(StrEnum):
     @classmethod
     def values(cls):
         return [action.value for action in cls]
+
+
+class GitLabIssueStatus(StrEnum):
+    OPENED = "opened"
+    CLOSED = "closed"
+
+    @classmethod
+    def get_choices(cls):
+        """Return choices formatted for dropdown selectors"""
+        return [(status.value, status.value.capitalize()) for status in cls]
diff --git a/src/sentry/integrations/services/repository/impl.py b/src/sentry/integrations/services/repository/impl.py
index 26af259d2ad153..1ea645d0cbf026 100644
--- a/src/sentry/integrations/services/repository/impl.py
+++ b/src/sentry/integrations/services/repository/impl.py
@@ -7,6 +7,7 @@
 from sentry.api.serializers import serialize
 from sentry.constants import ObjectStatus
 from sentry.db.postgres.transactions import enforce_constraints
+from sentry.integrations.gitlab.tasks import update_all_project_webhooks
 from sentry.integrations.models.repository_project_path_config import RepositoryProjectPathConfig
 from sentry.integrations.services.repository import RepositoryService, RpcRepository
 from sentry.integrations.services.repository.model import RpcCreateRepository
@@ -256,7 +257,6 @@ def disassociate_organization_integration(
             RepositoryProjectPathConfig.objects.filter(
                 organization_integration_id=organization_integration_id
             ).delete()
-
             # Delete Seer project preference handoffs associated with this integration
             transaction.on_commit(
                 lambda: cleanup_seer_automation_handoffs_for_integration.apply_async(
@@ -267,3 +267,14 @@ def disassociate_organization_integration(
                 ),
                 using=router.db_for_write(Repository),
             )
+
+    def schedule_update_gitlab_project_webhooks(
+        self,
+        *,
+        organization_id: int,
+        integration_id: int,
+    ) -> None:
+        update_all_project_webhooks.delay(
+            integration_id=integration_id,
+            organization_id=organization_id,
+        )
diff --git a/src/sentry/integrations/services/repository/service.py b/src/sentry/integrations/services/repository/service.py
index 51cb81c98ba835..a34ec830c01ff3 100644
--- a/src/sentry/integrations/services/repository/service.py
+++ b/src/sentry/integrations/services/repository/service.py
@@ -114,5 +114,18 @@ def disassociate_organization_integration(
         This will also delete code owners, and code mapping associated with matching repositories.
         """
 
+    @cell_rpc_method(resolve=ByOrganizationId())
+    @abstractmethod
+    def schedule_update_gitlab_project_webhooks(
+        self,
+        *,
+        organization_id: int,
+        integration_id: int,
+    ) -> None:
+        """
+        Schedules a task to update all GitLab project webhooks for an integration.
+        This is used when sync settings change and webhooks need to be updated.
+        """
+
 
 repository_service = RepositoryService.create_delegation()
diff --git a/tests/sentry/integrations/api/endpoints/test_organization_integration_details.py b/tests/sentry/integrations/api/endpoints/test_organization_integration_details.py
index fadfba3e03e059..e83060a37bf43f 100644
--- a/tests/sentry/integrations/api/endpoints/test_organization_integration_details.py
+++ b/tests/sentry/integrations/api/endpoints/test_organization_integration_details.py
@@ -60,7 +60,9 @@ class OrganizationIntegrationDetailsPostTest(OrganizationIntegrationDetailsTest)
 
     def test_update_config(self) -> None:
         config = {"setting": "new_value", "setting2": "baz"}
-        with patch("sentry.integrations.gitlab.integration.update_all_project_webhooks"):
+        with patch(
+            "sentry.integrations.gitlab.integration.repository_service.schedule_update_gitlab_project_webhooks"
+        ):
             self.get_success_response(self.organization.slug, self.integration.id, **config)
 
         org_integration = OrganizationIntegration.objects.get(
diff --git a/tests/sentry/integrations/gitlab/test_integration.py b/tests/sentry/integrations/gitlab/test_integration.py
index ca864cc9ac50b8..d9290a180bf94d 100644
--- a/tests/sentry/integrations/gitlab/test_integration.py
+++ b/tests/sentry/integrations/gitlab/test_integration.py
@@ -15,11 +15,16 @@
 from sentry.integrations.gitlab.constants import GITLAB_WEBHOOK_VERSION, GITLAB_WEBHOOK_VERSION_KEY
 from sentry.integrations.gitlab.integration import GitlabIntegration, GitlabIntegrationProvider
 from sentry.integrations.models.integration import Integration
+from sentry.integrations.models.integration_external_project import IntegrationExternalProject
 from sentry.integrations.models.organization_integration import OrganizationIntegration
 from sentry.integrations.pipeline import IntegrationPipeline
 from sentry.integrations.services.integration import integration_service
 from sentry.integrations.types import ExternalProviders
-from sentry.shared_integrations.exceptions import ApiForbiddenError, IntegrationConfigurationError
+from sentry.shared_integrations.exceptions import (
+    ApiForbiddenError,
+    IntegrationConfigurationError,
+    IntegrationError,
+)
 from sentry.silo.base import SiloMode
 from sentry.silo.util import PROXY_BASE_PATH, PROXY_OI_HEADER, PROXY_SIGNATURE_HEADER
 from sentry.testutils.cases import APITestCase, IntegrationTestCase
@@ -224,6 +229,7 @@ def test_get_organization_config(self) -> None:
         fields = installation.get_organization_config()
 
         assert [field["name"] for field in fields] == [
+            "sync_status_forward",
             "sync_reverse_assignment",
             "sync_forward_assignment",
             "sync_comments",
@@ -246,7 +252,9 @@ def test_update_organization_config(self) -> None:
         # Initial config should be empty
         assert org_integration.config == {}
 
-        with patch("sentry.integrations.gitlab.integration.update_all_project_webhooks"):
+        with patch(
+            "sentry.integrations.gitlab.integration.repository_service.schedule_update_gitlab_project_webhooks"
+        ):
             # Update configuration
             data = {"sync_reverse_assignment": True, "other_option": "test_value"}
             installation.update_organization_config(data)
@@ -276,7 +284,9 @@ def test_update_organization_config_preserves_existing(self) -> None:
         }
         org_integration.save()
 
-        with patch("sentry.integrations.gitlab.integration.update_all_project_webhooks"):
+        with patch(
+            "sentry.integrations.gitlab.integration.repository_service.schedule_update_gitlab_project_webhooks"
+        ):
             # Update configuration with new data
             data = {"sync_reverse_assignment": True, "new_key": "new_value"}
             installation.update_organization_config(data)
@@ -557,16 +567,16 @@ def test_update_organization_config_triggers_webhook_update_on_outdated_version(
         )
 
         with patch(
-            "sentry.integrations.gitlab.integration.update_all_project_webhooks"
-        ) as mock_task:
+            "sentry.integrations.gitlab.integration.repository_service.schedule_update_gitlab_project_webhooks"
+        ) as mock_schedule_webhooks:
             # Update configuration
             data = {"sync_reverse_assignment": True}
             installation.update_organization_config(data)
 
             # Verify task was called with correct arguments
-            mock_task.delay.assert_called_once_with(
-                integration_id=integration.id,
+            mock_schedule_webhooks.assert_called_once_with(
                 organization_id=self.organization.id,
+                integration_id=integration.id,
             )
 
         # Verify config was updated (but version stays at 0 since task was mocked)
@@ -603,14 +613,14 @@ def test_update_organization_config_does_not_trigger_webhook_update_on_current_v
         )
 
         with patch(
-            "sentry.integrations.gitlab.integration.update_all_project_webhooks"
-        ) as mock_task:
+            "sentry.integrations.gitlab.integration.repository_service.schedule_update_gitlab_project_webhooks"
+        ) as mock_schedule_webhooks:
             # Update configuration
             data = {"sync_reverse_assignment": True}
             installation.update_organization_config(data)
 
             # Verify task was NOT called
-            mock_task.delay.assert_not_called()
+            mock_schedule_webhooks.assert_not_called()
 
         # Verify config was still updated
         org_integration = integration_service.get_organization_integration(
@@ -647,16 +657,16 @@ def test_update_organization_config_triggers_webhook_update_on_missing_version(
         )
 
         with patch(
-            "sentry.integrations.gitlab.integration.update_all_project_webhooks"
-        ) as mock_task:
+            "sentry.integrations.gitlab.integration.repository_service.schedule_update_gitlab_project_webhooks"
+        ) as mock_schedule_webhooks:
             # Update configuration
             data = {"sync_comments": True}
             installation.update_organization_config(data)
 
             # Verify task was called
-            mock_task.delay.assert_called_once_with(
-                integration_id=integration.id,
+            mock_schedule_webhooks.assert_called_once_with(
                 organization_id=self.organization.id,
+                integration_id=integration.id,
             )
 
         # Verify config was updated (but version is not set since task was mocked)

Leaderboard for this case

easy · 8 of 9 bots fully caught it (89% solve rate) · 94% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 Claude Code (Opus 5.5) solved 2/2 100.0% 3 0
2 Cubic solved 2/2 100.0% 3 0
3 cursor solved 2/2 100.0% 2 0
4 Drape (Deep Review) solved 2/2 100.0% 4 0
5 Drape (Review) solved 2/2 100.0% 5 0
6 Mjolnir (Opus 5.5) solved 2/2 100.0% 3 0
7 Mjolnir (Sonnet 5.5) solved 2/2 100.0% 4 0
8 qodo solved 2/2 100.0% 5 1
9 greptile partial 1/2 50.0% 2 0

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ exact
valid · matches d1 · impact medium
valid · matches d2 · impact medium
valid · impact low
The search endpoint returns label=name_with_namespace (e.g. "GetSentry / Sentry") with value=path_with_namespace. update_organization_config saves name=project_path, and get_organization_config uses project.name as the label. So after saving, the label the user sees changes from the display name to the path slug. This is real but cosmetic. [grounded: diff] [consensus 3/3: valid=3]
raw comments (3)
src/sentry/integrations/gitlab/search.py:82
The project search endpoint now returns `path_with_namespace` (for example `group/sub/proj`) as the value instead of the numeric project id. The create-issue form's `project` field (issues.py `get_create_issue_config`) uses this same endpoint, so `create_issue` gets a path. It passes the path unencoded to `client.create_issue` and `client.get_project`, which drop it straight into `/projects/{project}/issues`. The slashes break the GitLab API URL, so creating an issue in any project picked from autocomplete fails. The path is also saved as the project default, but `create_default_repo_choice` returns the numeric id, so defaults no longer line up.
src/sentry/integrations/gitlab/integration.py:375
All existing IntegrationExternalProject rows are deleted before each mapping's status values are checked. The check runs inside the create loop, outside any transaction. If a later mapping has a bad status (anything other than 'opened'/'closed'), the code raises IntegrationError after the old mappings are gone and some new ones are already created. The user's status-sync configuration is left partly wiped. Validate everything before deleting, and wrap the delete and the creates in a transaction.
src/sentry/integrations/gitlab/integration.py:390
Mappings are stored with `name=project_path`, and `get_organization_config` shows that as the dropdown label. Search results use `name_with_namespace` as the label, so a configured project's label changes after saving and no longer matches what the user picked.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ exact
valid · matches d1 · impact medium
valid · impact low
The new sync_status_forward branch in update_organization_config never calls check_feature_flag(), so a POST with mappings still creates IntegrationExternalProject rows and sets the config key to True. should_sync in mixins/issues.py only reads org_integration.config, and sync_status_outbound has no flag check of its own. That means outbound status sync can be turned on even when the feature flag is off. By contrast, the inbound path is gated in get_resolve_sync_action. [grounded: diff] [consensus 5/5: valid=5]
valid · matches d2 · impact medium
raw comments (4)
src/sentry/integrations/gitlab/search.py:82
<!-- cubic:v=041e2886-e8bb-4342-a90d-5e2b2bebe44a --> <!-- cubic:review-run=563e88bc-1aee-5b24-973f-bb42a9aadb26 --> <!-- metadata:{"confidence":10} --> P1: When a user selects a project from this autocomplete, creating an issue passes `group/project` to GitLab without URL-encoding it, so GitLab receives the wrong `/projects/.../issues` route and creation fails. Encode the project path in the client before constructing the create-issue and subsequent project URLs. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At src/sentry/integrations/gitlab/search.py, line 82: <comment>When a user selects a project from this autocomplete, creating an issue passes `group/project` to GitLab without URL-encoding it, so GitLab receives the wrong `/projects/.../issues` route and creation fails. Encode the project path in the client before constructing the create-issue and subsequent project URLs.</comment> <file context> @@ -77,7 +77,10 @@ def handle_search_repositories( - {"label": project["name_with_namespace"], "value": str(project["id"])} + { + "label": project["name_with_namespace"], + "value": project["path_with_namespace"], + } for project in response </file context> ``` </details>
src/sentry/integrations/gitlab/integration.py:362
<!-- cubic:v=fb6f3c7c-17ae-46df-8075-cdb7b80e0533 --> <!-- cubic:review-run=563e88bc-1aee-5b24-973f-bb42a9aadb26 --> <!-- metadata:{"confidence":8} --> P2: When the GitLab project-management flag is disabled, this branch still persists submitted mappings and enables outbound status sync. Reject or ignore `sync_status_forward` unless `check_feature_flag()` is enabled. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At src/sentry/integrations/gitlab/integration.py, line 362: <comment>When the GitLab project-management flag is disabled, this branch still persists submitted mappings and enables outbound status sync. Reject or ignore `sync_status_forward` unless `check_feature_flag()` is enabled.</comment> <file context> @@ -306,6 +358,43 @@ def update_organization_config(self, data: MutableMapping[str, Any]) -> None: config = self.org_integration.config + # Handle status sync configuration + if "sync_status_forward" in data: + project_mappings = data.pop("sync_status_forward") + </file context> ``` </details>
src/sentry/integrations/gitlab/integration.py:374
<!-- cubic:v=4eab7d83-2112-47f0-802c-59ebde2b9158 --> <!-- cubic:review-run=563e88bc-1aee-5b24-973f-bb42a9aadb26 --> <!-- metadata:{"confidence":10} --> P2: When one mapping is invalid after an earlier valid mapping, this delete runs first and the rejected request permanently removes the old mappings while retaining only partial new state. Validate every mapping before deleting, or wrap deletion and recreation in one transaction. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At src/sentry/integrations/gitlab/integration.py, line 374: <comment>When one mapping is invalid after an earlier valid mapping, this delete runs first and the rejected request permanently removes the old mappings while retaining only partial new state. Validate every mapping before deleting, or wrap deletion and recreation in one transaction.</comment> <file context> @@ -306,6 +358,43 @@ def update_organization_config(self, data: MutableMapping[str, Any]) -> None: + + data["sync_status_forward"] = bool(project_mappings) + + IntegrationExternalProject.objects.filter( + organization_integration_id=self.org_integration.id + ).delete() </file context> ``` </details>
PR-level
<!-- cubic:review-summary:start --> **3 issues found** across 10 files <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="src/sentry/integrations/gitlab/search.py"> <violation number="1" location="src/sentry/integrations/gitlab/search.py:82"> P1: When a user selects a project from this autocomplete, creating an issue passes `group/project` to GitLab without URL-encoding it, so GitLab receives the wrong `/projects/.../issues` route and creation fails. Encode the project path in the client before constructing the create-issue and subsequent project URLs.</violation> </file> <file name="src/sentry/integrations/gitlab/integration.py"> <violation number="1" location="src/sentry/integrations/gitlab/integration.py:362"> P2: When the GitLab project-management flag is disabled, this branch still persists submitted mappings and enables outbound status sync. Reject or ignore `sync_status_forward` unless `check_feature_flag()` is enabled.</violation> <violation number="2" location="src/sentry/integrations/gitlab/integration.py:374"> P2: When one mapping is invalid after an earlier valid mapping, this delete runs first and the rejected request permanently removes the old mappings while retaining only partial new state. Validate every mapping before deleting, or wrap deletion and recreation in one transaction.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/71/ai_pr_review_github_delivery_41e39d441eb1ed9cde1b8dc729afcb7f1e69a1d0fea2c8e91e47fa3c83a10989?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F71)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_41e39d441eb1ed9cde1b8dc729afcb7f1e69a1d0fea2c8e91e47fa3c83a10989:8b191b0b6e34b6fa31ddb3150025580799f4f472:563e88bc-1aee-5b24-973f-bb42a9aadb26 -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ exact
valid · matches d1 · impact medium
valid · matches d2 · impact medium
raw comments (3)
src/sentry/integrations/gitlab/search.py:83
### Search value breaks GitLab issue forms **High Severity** <!-- DESCRIPTION START --> The shared GitLab search endpoint now returns `path_with_namespace` instead of the numeric project id. Create and link issue forms still treat that value as a raw project id and pass it unencoded into `create_issue` and `get_project`, so GitLab receives paths like `/projects/getsentry/sentry` and those requests fail. `search_project_issues` was updated to quote the path, but the rest of the issue form flow was not. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 28a79487-1c0a-4349-b724-fc00a64a4986 --> <!-- LOCATIONS START src/sentry/integrations/gitlab/search.py#L79-L83 src/sentry/integrations/gitlab/client.py#L218-L241 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`src/sentry/integrations/gitlab/client.py#L218-L241`](https://github.com/drape-io/crbench-cursor-2026-09/blob/172950336048e45a20c69ddcde574b8b5b119207/src/sentry/integrations/gitlab/client.py#L218-L241) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90Ojc5ZjZkZDJiLWYzNWQtNGYxNi1iZTJkLTMyM2I0YWQ2MWUwNSIsImVuY3J5cHRpb25LZXkiOiJNVUd1NzZseGxZbFMtNnZweW9hbS00R2JadkJ4YzdJdXY4WWthRzcxX0RjIiwiYnJhbmNoIjoidDItc2VudHJ5LTEwNzIxNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90Ojc5ZjZkZDJiLWYzNWQtNGYxNi1iZTJkLTMyM2I0YWQ2MWUwNSIsImVuY3J5cHRpb25LZXkiOiJNVUd1NzZseGxZbFMtNnZweW9hbS00R2JadkJ4YzdJdXY4WWthRzcxX0RjIiwiYnJhbmNoIjoidDItc2VudHJ5LTEwNzIxNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjczLCJjb21taXRTaGEiOiIxNzI5NTAzMzYwNDhlNDVhMjBjNjlkZGNkZTU3NGI4YjViMTE5MjA3IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 172950336048e45a20c69ddcde574b8b5b119207. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
src/sentry/integrations/gitlab/integration.py:388
### Invalid statuses wipe existing project mappings **Medium Severity** <!-- DESCRIPTION START --> `update_organization_config` deletes all `IntegrationExternalProject` rows before it validates `on_resolve` and `on_unresolve`. An invalid status raises `IntegrationError` after the delete, so previously saved GitLab status mappings are removed even though the update did not succeed. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: a413233e-088a-4a92-9e8c-43c27ecf5219 --> <!-- LOCATIONS START src/sentry/integrations/gitlab/integration.py#L373-L388 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmNhYWQ5ZWJmLTQ3NmUtNDhiMy04ZjhhLWY2OGI4ZjY2ZTJjNSIsImVuY3J5cHRpb25LZXkiOiJ4Vlpaa0JyX0hIbmEzQVhjNFlBRXhLUTJzbVpCYWI1NXExeWpOXzNQekdjIiwiYnJhbmNoIjoidDItc2VudHJ5LTEwNzIxNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmNhYWQ5ZWJmLTQ3NmUtNDhiMy04ZjhhLWY2OGI4ZjY2ZTJjNSIsImVuY3J5cHRpb25LZXkiOiJ4Vlpaa0JyX0hIbmEzQVhjNFlBRXhLUTJzbVpCYWI1NXExeWpOXzNQekdjIiwiYnJhbmNoIjoidDItc2VudHJ5LTEwNzIxNiIsInJlcG9Pd25lciI6ImRyYXBlLWlvIiwicmVwb05hbWUiOiJjcmJlbmNoLWN1cnNvci0yMDI2LTA5IiwicHJOdW1iZXIiOjczLCJjb21taXRTaGEiOiIxNzI5NTAzMzYwNDhlNDVhMjBjNjlkZGNkZTU3NGI4YjViMTE5MjA3IiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 172950336048e45a20c69ddcde574b8b5b119207. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTphMzgyNDQ4Ny02ZjcwLTRkNGItYTk3Yy03YzM0ZGZmNjhkZmYiLCJlbmNyeXB0aW9uS2V5IjoiVlNPdXhLRzF5bmdjYTZCWjVEZ0hsLXd2ZEVackY2Xzc4QVhaYzlNbzB6SSIsImJyYW5jaCI6InQyLXNlbnRyeS0xMDcyMTYiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 172950336048e45a20c69ddcde574b8b5b119207. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ exact
valid · matches d1 · impact medium
valid · impact low
The new code calls .values() and .get() on user-supplied data without checking its type. A list or bool raises AttributeError, which is not an IntegrationError, so the request fails with a 500 instead of a validation error. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact medium
valid · impact low
The new write path never calls check_feature_flag(), so an API caller can create IntegrationExternalProject rows and set sync_status_forward=True while the flag is off. sync_status_outbound also does not check the flag, so outbound sync can run for orgs that are not gated in. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
src/sentry/integrations/gitlab/search.py:82
**Create/link issue project picker now breaks** This endpoint also feeds the project select on the create/link issue forms. The picked value is now a path like `group/proj`, which `create_issue`/`get_project` put into the URL unencoded, so GitLab returns 404. Keep returning the numeric id, or URL-encode the project in the client. ``` src/sentry/integrations/gitlab/search.py:80 { src/sentry/integrations/gitlab/search.py:81 "label": project["name_with_namespace"], src/sentry/integrations/gitlab/search.py:82 "value": project["path_with_namespace"], src/sentry/integrations/gitlab/search.py:83 } src/sentry/integrations/gitlab/client.py:224 return self.get(GitLabApiClientPath.project.format(project=project_id)) src/sentry/integrations/gitlab/client.py:236 def create_issue(self, project, data): src/sentry/integrations/gitlab/client.py:237 """Create an issue src/sentry/integrations/gitlab/client.py:239 See https://docs.gitlab.com/ee/api/issues.html#new-issue src/sentry/integrations/gitlab/client.py:240 """ src/sentry/integrations/gitlab/client.py:241 return self.post(GitLabApiClientPath.issues.format(project=project), data=data) ```
src/sentry/integrations/gitlab/integration.py:368
**Malformed sync_status_forward causes 500 error** `project_mappings` and each mapping are assumed to be dicts. A list, a boolean, or a non-dict value crashes on `.values()` or `.get()` with a server error instead of returning a validation error. Raise IntegrationError when `project_mappings` or any mapping is not a dict. ``` src/sentry/integrations/gitlab/integration.py:362 if "sync_status_forward" in data: src/sentry/integrations/gitlab/integration.py:363 project_mappings = data.pop("sync_status_forward") src/sentry/integrations/gitlab/integration.py:365 # Validate that all mappings have both statuses src/sentry/integrations/gitlab/integration.py:366 if any( src/sentry/integrations/gitlab/integration.py:367 not mapping.get("on_unresolve") or not mapping.get("on_resolve") src/sentry/integrations/gitlab/integration.py:368 for mapping in project_mappings.values() src/sentry/integrations/gitlab/integration.py:369 ): ```
src/sentry/integrations/gitlab/integration.py:374
**Invalid status wipes existing project mappings** Old mappings are deleted before each status is validated, with no transaction. A bad status in a later entry errors after the old rows are gone and earlier ones are recreated. Validate all mappings first, then delete and create inside one transaction. ``` src/sentry/integrations/gitlab/integration.py:374 IntegrationExternalProject.objects.filter( src/sentry/integrations/gitlab/integration.py:375 organization_integration_id=self.org_integration.id src/sentry/integrations/gitlab/integration.py:376 ).delete() src/sentry/integrations/gitlab/integration.py:378 for project_path, statuses in project_mappings.items(): src/sentry/integrations/gitlab/integration.py:379 # Validate status values src/sentry/integrations/gitlab/integration.py:380 valid_statuses = {GitLabIssueStatus.OPENED.value, GitLabIssueStatus.CLOSED.value} src/sentry/integrations/gitlab/integration.py:381 if statuses["on_resolve"] not in valid_statuses: src/sentry/integrations/gitlab/integration.py:382 raise IntegrationError( src/sentry/integrations/gitlab/integration.py:383 f"Invalid resolve status: {statuses['on_resolve']}. Must be 'opened' or 'closed'." src/sentry/integrations/gitlab/integration.py:384 ) ```
src/sentry/integrations/gitlab/integration.py:362
**Status mappings saved without the feature flag** `update_organization_config` writes `sync_status_forward` mappings and turns the setting on even when `check_feature_flag()` is off. The field is only hidden in `get_organization_config`. Ignore or reject sync_status_forward when check_feature_flag() is false. ``` src/sentry/integrations/gitlab/integration.py:362 if "sync_status_forward" in data: src/sentry/integrations/gitlab/integration.py:363 project_mappings = data.pop("sync_status_forward") src/sentry/integrations/gitlab/integration.py:365 # Validate that all mappings have both statuses src/sentry/integrations/gitlab/integration.py:366 if any( src/sentry/integrations/gitlab/integration.py:299 if self.check_feature_flag(): src/sentry/integrations/gitlab/issue_sync.py:31 def check_feature_flag(self) -> bool: src/sentry/integrations/gitlab/issue_sync.py:32 """ src/sentry/integrations/gitlab/issue_sync.py:33 A temporary method so we can gate GitLab project management features. src/sentry/integrations/gitlab/issue_sync.py:34 """ src/sentry/integrations/gitlab/issue_sync.py:35 return features.has( ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ exact
valid · matches d1 · impact medium
valid · matches d2 · impact medium
valid · impact low
The new code calls `.values()` and `.get()` on user-supplied data and never checks its type. A non-dict payload therefore raises AttributeError, which surfaces as an unhandled server error instead of an IntegrationError. [grounded: tree src/sentry/integrations/gitlab/integration.py] [consensus 3/3: valid=3]
valid · impact medium
The create-issue 'project' field autocompletes from the same search endpoint, so its values are now namespace paths, and 'project' is a persisted default. `create_default_repo_choice` passes that value unencoded to `client.get_project`, which formats it raw into the URL path. The lookup fails, the ApiError is caught, and the code returns ("", ""). [grounded: tree src/sentry/integrations/gitlab/search.py] [consensus 3/3: valid=3]
valid · impact low
The IntegrationExternalProject model has `external_id = models.CharField(max_length=64)`. GitLab paths with nested groups can exceed 64 characters, and nothing validates the length, so the insert fails with a database error. [grounded: diff] [consensus 3/3: valid=3]
raw comments (5)
src/sentry/integrations/gitlab/search.py:82
**Project picker now returns path, breaking issue creation** The project search now returns `path_with_namespace` instead of the numeric id. The create-issue flow puts this value unquoted into URLs (`get_project`, `create_issue`, `create_comment`), so the slash breaks the path. Keep numeric ids for the issue-create flow, or URL-quote project ids in get_project, create_issue and create_comment. ``` src/sentry/integrations/gitlab/search.py:80 { src/sentry/integrations/gitlab/search.py:81 "label": project["name_with_namespace"], src/sentry/integrations/gitlab/search.py:82 "value": project["path_with_namespace"], src/sentry/integrations/gitlab/search.py:83 } src/sentry/integrations/gitlab/client.py:224 return self.get(GitLabApiClientPath.project.format(project=project_id)) src/sentry/integrations/gitlab/client.py:241 return self.post(GitLabApiClientPath.issues.format(project=project), data=data) src/sentry/integrations/gitlab/client.py:273 GitLabApiClientPath.issue_notes.format(project_id=repo, issue_id=issue_id), data=data src/sentry/integrations/gitlab/issues.py:60 project = client.get_project(default_repo) src/sentry/integrations/gitlab/issues.py:61 except (ApiError, ApiUnauthorized): src/sentry/integrations/gitlab/issues.py:62 return ("", "") ```
src/sentry/integrations/gitlab/integration.py:374
**Saved project mappings deleted before validation** `update_organization_config` deletes all `IntegrationExternalProject` rows before validating each mapping's statuses, and creates rows one by one with no transaction. An invalid status in a later mapping raises after the delete. Validate all mappings first, then delete and recreate inside a transaction. ``` src/sentry/integrations/gitlab/integration.py:365 # Validate that all mappings have both statuses src/sentry/integrations/gitlab/integration.py:366 if any( src/sentry/integrations/gitlab/integration.py:367 not mapping.get("on_unresolve") or not mapping.get("on_resolve") src/sentry/integrations/gitlab/integration.py:368 for mapping in project_mappings.values() ```
src/sentry/integrations/gitlab/integration.py:366
**Malformed sync_status_forward causes 500** The mappings are used as dicts (`project_mappings.values()`, `mapping.get`) with no type check. A non-dict payload or non-dict mapping value raises AttributeError, producing a server error rather than a validation error. Check that the payload and each value is a dict and raise IntegrationError otherwise. ``` src/sentry/integrations/gitlab/integration.py:362 if "sync_status_forward" in data: src/sentry/integrations/gitlab/integration.py:363 project_mappings = data.pop("sync_status_forward") src/sentry/integrations/gitlab/integration.py:365 # Validate that all mappings have both statuses src/sentry/integrations/gitlab/integration.py:366 if any( ```
src/sentry/integrations/gitlab/issues.py:60
**Saved default GitLab project silently stops loading** The project field is a persisted default (`get_persisted_default_config_fields`), and the search now saves a path like `group/proj` as its value. `create_default_repo_choice` passes it to `client.get_project` unencoded, so the lookup fails and returns an empty default. URL-encode the project in `get_project`, or in `create_default_repo_choice`. ``` src/sentry/integrations/gitlab/search.py:80 { src/sentry/integrations/gitlab/search.py:81 "label": project["name_with_namespace"], src/sentry/integrations/gitlab/search.py:82 "value": project["path_with_namespace"], src/sentry/integrations/gitlab/search.py:83 } ```
src/sentry/integrations/gitlab/integration.py:390
**Long project paths overflow `external_id` column** The project path is stored in `IntegrationExternalProject.external_id`, which is `max_length=64` (and `name` is 128). GitLab `path_with_namespace` values with nested groups can exceed that. Validate length and return an error, or widen the columns. ``` src/sentry/integrations/gitlab/integration.py:390 IntegrationExternalProject.objects.create( src/sentry/integrations/gitlab/integration.py:391 organization_integration_id=self.org_integration.id, src/sentry/integrations/gitlab/integration.py:392 external_id=project_path, src/sentry/integrations/gitlab/integration.py:393 name=project_path, ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✗ —
d2 medium ✓ off by one
valid · matches d2 · impact medium
valid · impact low
The new update_organization_config handling of sync_status_forward never calls check_feature_flag(). The flag is only checked when the UI field is built in get_organization_config. The base should_sync (mixins/issues.py) only reads the config key, and the new sync_status_outbound has no flag check either. So an org without the project-management flag can submit the setting directly and turn on outbound status sync. [grounded: tree src/sentry/integrations/gitlab/integration.py] [consensus 3/3: valid=3]
raw comments (3)
src/sentry/integrations/gitlab/integration.py:381
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Mapping Updates Are Nonatomic** The method deletes every existing project mapping before validating each replacement. If a later mapping has an invalid status, the endpoint returns a 400 after the old mappings have already been deleted and any earlier replacements committed. This leaves status synchronization partially configured even though the request was rejected. Validate the complete payload before deleting records and replace the mappings within a transaction.
src/sentry/integrations/gitlab/integration.py:363
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Feature Gate Can Be Bypassed** The project-management flag only controls whether this setting is displayed. The update path still accepts `sync_status_forward` without checking that flag, and the endpoint passes request data directly to it. An organization with general issue sync but without GitLab project-management access can therefore submit the setting manually and trigger outbound GitLab status updates. Enforce the project-management flag when accepting this setting.
PR-level
<h3>Greptile Summary</h3> This PR adds configurable outbound Sentry-to-GitLab issue status synchronization, switches project selectors to namespace paths, and routes GitLab webhook updates through the cell-local repository service. - Adds per-project resolved and unresolved status mappings. - Implements GitLab issue state lookup and close/reopen transitions. - Adds path-aware project searching and encoding. - Expands integration and search coverage for the new behavior. - The configuration update currently risks partial data loss on rejected requests and does not enforce its feature gate server-side. <h3>Confidence Score: 3/5</h3> The PR is not safe to merge until project-mapping updates are made atomic and the GitLab project-management feature gate is enforced on configuration writes. A rejected mapping update can permanently delete or partially replace previously valid configuration, and clients can enable the gated outbound synchronization behavior by submitting its configuration key directly. **Files Needing Attention:** src/sentry/integrations/gitlab/integration.py <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | src/sentry/integrations/gitlab/integration.py | Adds the status-mapping configuration UI and persistence, but replacement is non-atomic and acceptance is not protected by the project-management feature gate. | | src/sentry/integrations/gitlab/issue_sync.py | Implements path-based outbound status synchronization with mapping lookup, current-state detection, and GitLab close/reopen transitions. | | src/sentry/integrations/gitlab/search.py | Changes repository selector values from numeric project IDs to namespace paths while preserving normalized issue linking. | | src/sentry/integrations/gitlab/client.py | URL-encodes project identifiers used by issue search. | | src/sentry/integrations/services/repository/service.py | Adds a cell-routed RPC method for scheduling GitLab webhook updates. | | src/sentry/integrations/services/repository/impl.py | Implements the repository service method by enqueueing the existing cell-silo webhook task. | | tests/sentry/integrations/gitlab/test_integration.py | Adds broad coverage for status mappings and outbound transitions, but does not cover preservation after a partially invalid replacement or feature-gate bypass. | </details> <details open><summary><h3>Sequence Diagram</h3></summary> ```mermaid sequenceDiagram participant Admin participant API as Integration Details API participant Config as GitlabIntegration participant DB as IntegrationExternalProject participant Task as Outbound Status Task participant GitLab Admin->>API: Submit per-project status mappings API->>Config: update_organization_config(data) Config->>DB: Replace project mappings Config-->>API: Persist sync_status_forward Task->>Config: sync_status_outbound(external_issue, state) Config->>DB: Load mapping by project path Config->>GitLab: GET current issue state alt State differs Config->>GitLab: "PUT state_event=close/reopen" else State already matches Config-->>Task: No update required end ``` </details> <!-- greptile_other_comments_section --> <sub>Reviews (1): Last reviewed commit: ["Update src/sentry/integrations/gitlab/cl..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/34f5c8a64865d194ec6a99bcb0d9d569add5b56a) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64284793)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ off by one
valid · matches d1 · impact medium
valid · impact high
The create-issue and link-issue forms in issues.py use the same `sentry-extensions-gitlab-search` autocomplete. That search now returns `path_with_namespace` instead of the numeric ID. `create_issue` passes `data.get("project")` unquoted to `client.create_issue(project=project_id, ...)` and `client.get_project(project_id)`, so the request URL becomes `/projects/group/project/...`, which GitLab does not accept. The persisted default goes through `create_default_repo_choice`'s unquoted `get_project` call, so it breaks the same way. Only `search_project_issues` was changed to quote the value. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact medium
raw comments (3)
src/sentry/integrations/gitlab/search.py:80
[P1] Project search now returns unencoded paths, which breaks GitLab issue creation The project search endpoint now returns `path_with_namespace` as the value instead of the numeric project ID. This endpoint is not only used by the new status-sync dropdown. It is also the autocomplete `url` for the `project` field in `get_create_issue_config` and `get_link_issue_config` (`issues.py`). So whenever a user picks a project from search in the "Create GitLab Issue" form, `create_issue` receives something like `group/sub/project`. It then calls `client.create_issue(project=project_id, ...)` and `client.get_project(project_id)`, and both put the value straight into `/projects/{project}/issues` and `/projects/{project}` without URL-encoding it. GitLab answers a path with raw `/` separators with a 404, so issue creation fails for any project chosen through search (the only exception is a pre-filled numeric default). The path is also saved as the persisted default `project`, so `create_default_repo_choice` → `get_project(path)` fails on later loads and the default is dropped. In this diff, only `search_issues` was updated to quote the project ID. `create_issue`, `get_project`, `get_issue`, `create_comment` and the other client methods still assume a numeric ID.
src/sentry/integrations/gitlab/search.py:80
[P1] Project search now returns paths, which breaks creating GitLab issues from Sentry The `sentry-extensions-gitlab-search` repository search is shared with the "project" select in the create-issue and link-issue forms (`issues.py` `get_create_issue_config`/`get_link_issue_config`), not only the new status-sync mapper. When a user picks a project from that autocomplete, the form now submits `group/subgroup/project` instead of the numeric ID. `GitlabIssuesSpec.create_issue` sends that value unquoted to `client.create_issue(project=...)` and `client.get_project(...)`, so the request goes to `/projects/group/project/issues`, which GitLab answers with a 404. Issue creation fails for any project chosen through search. The stored `"project": project_id` default then has the same problem: `create_default_repo_choice` calls `get_project` on the unquoted path, so it fails and the default comes back empty. It also no longer matches the numeric-ID `choices` built by `get_repository_choices`. Only `search_project_issues` was updated to quote the value. Either use a separate field or endpoint for the status-sync mapper, or quote the value everywhere it is used as a project ID.
src/sentry/integrations/gitlab/integration.py:375
[P3] Existing status-sync mappings are deleted before the new status values are validated `update_organization_config` deletes every `IntegrationExternalProject` row for the org integration and only then checks each mapping's `on_resolve`/`on_unresolve` against `opened`/`closed`, raising `IntegrationError` partway through the loop. The organization integration details endpoint does not wrap this call in a transaction. If a request contains an invalid status (for example on the second project), the user gets a 400, but all of their previous mappings are already gone and only the mappings before the bad entry have been recreated. The `sync_status_forward` config flag is also left stale. Run the status validation together with the existing required-field check, before the delete.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ exact
valid · matches d1 · impact medium
valid · matches d2 · impact medium
valid · impact high
The search endpoint also backs the create-issue project select in issues.py (autocomplete_url = reverse("sentry-extensions-gitlab-search"...)). create_issue passes data["project"] straight into client.create_issue/get_project, and these format it into "/projects/{project}" without quoting. A namespaced path like group/proj therefore produces a broken URL. The change to the search value is what introduces this. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
The new code deletes all existing IntegrationExternalProject rows first. Only afterwards does it check, inside the create loop, that each status value is valid, and it raises IntegrationError midway with no transaction.atomic. An invalid status therefore leaves the earlier mappings deleted or only partly recreated. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
src/sentry/integrations/gitlab/search.py:80
[P1] Search now returns project paths that the create/link-issue flows send to the GitLab API unencoded handle_search_repositories` feeds the "GitLab Project" select in both the create-issue and link-issue forms (`GitlabIssuesSpec.get_create_issue_config` and `get_link_issue_config`). It now returns `path_with_namespace` (e.g. `group/sub/proj`) instead of the numeric id, and it does so unconditionally, whether or not the project-management flag is on. Those flows pass the value straight into `client.create_issue(project=...)`, `client.get_project(...)`, `client.get_issue(project_id, ...)` and `client.create_comment(repo=...)`, and the client formats it into the URL without `quote(..., safe="")`. The unencoded slashes split the path, so GitLab returns 404 and creating or linking a GitLab issue from the UI fails for every project. Only `search_project_issues` was changed to encode. Either keep the id as the value, or encode in all of these client methods, and add a test that covers the create and link flows
src/sentry/integrations/gitlab/integration.py:372
[P2] Existing external-project mappings are deleted before the new ones are validated update_organization_config` calls `IntegrationExternalProject.objects.filter(...).delete()` first. The loop then validates each `on_resolve` and `on_unresolve` value and raises `IntegrationError` on a bad one. There is no transaction around the delete, the loop and the creates. A request containing an invalid status value, or one that fails partway through the creates, therefore leaves the org's previously saved status-sync mappings permanently wiped. Validate every mapping before deleting, or wrap the replace in a transaction
src/sentry/integrations/gitlab/search.py:79
[P1] GitLab project search now returns a path that unquoted create/link-issue calls can't use handle_search_repositories` changed its `value` from the numeric project ID to `path_with_namespace`. This endpoint also backs the `project` select in the existing create-issue and link-issue forms (`get_create_issue_config` and `get_link_issue_config` in `issues.py` use the same autocomplete URL). That path is later passed unencoded in `issues.py`: `create_issue` calls `client.create_issue(project=project_id)` and `client.get_project(project_id)`, and `get_issue` calls `client.get_issue(project_id, ...)` and `client.get_project(project_id)`. The client formats these straight into the URL, so a value like `group/sub/proj` adds extra path segments and GitLab returns 404. Creating or linking a GitLab issue after picking a project from the dropdown then fails with an `IntegrationError`. The author encoded the path in `search_project_issues` and in `sync_status_outbound`, but not in these callers. The default and choices still use the numeric ID, so the two sources of the field now disagree
src/sentry/integrations/gitlab/integration.py:373
[P2] Existing external-project mappings are deleted before the new values are validated update_config` deletes all `IntegrationExternalProject` rows and only then loops over the mappings to check that each status is `opened` or `closed`. The loop also creates rows as it goes, and none of it runs in a transaction. If any mapping has an invalid status, it raises `IntegrationError` after the delete. The user's previously saved outbound status-sync configuration is then gone, or only partly recreated, and the config is never saved. Validate every mapping first, then delete and create inside `transaction.atomic
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 medium ✓ off by one
d2 medium ✓ off by one
invalid
make_external_key prepends the domain_name to the path#iid key, so the stored ExternalIssue key has the domain:path#iid format that split_external_issue_key expects. Because of that, linked issues do sync. [invalid: contradiction] [consensus 3/3: invalid=3]
valid · impact low
The new code calls .values() and .get() on request data that has not been validated. A list, string or null payload raises AttributeError instead of IntegrationError, so the endpoint returns a 500 rather than a 400. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d1 · impact medium
valid · matches d2 · impact medium
valid · impact medium
update_organization_config accepts sync_status_forward without calling check_feature_flag(), and sync_status_outbound has no flag check either. The outbound task gates only on integrations-issue-sync and should_sync, so a direct API request can enable outbound sync while the rollout flag is off. Before this change the method raised NotImplementedError, so this exposure is new. [grounded: diff] [consensus 3/3: valid=3]
raw comments (7)
src/sentry/integrations/gitlab/issue_sync.py:175
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Linked issues never sync their status <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>sync_status_outbound</i></b> passes <b><i>external_issue.key</i></b> to <b><i>split_external_issue_key</i></b>, which requires a domain prefix that the normal create and link flows do not store. Issues linked through those flows use <b><i>path_with_namespace#iid</i></b>, so they return through the invalid-key branch before mapping lookup or any GitLab request. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Outbound status synchronization rejects the domain-less external issue keys produced by normal GitLab issue creation and linking. ## Fix Focus Areas - src/sentry/integrations/gitlab/issue_sync.py[39-59] - src/sentry/integrations/gitlab/issue_sync.py[170-182] - src/sentry/integrations/gitlab/issues.py[115-123] - src/sentry/integrations/gitlab/issues.py[201-208] ## Recommended Fix Update external-key parsing to support both `domain:path#iid` and `path#iid`, then add outbound-sync tests using keys returned by the actual create and link flows rather than only domain-prefixed fixtures. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
src/sentry/integrations/gitlab/integration.py:368
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 4\. Malformed settings return server errors <code>🐞 Bug</code> <code>☼ Reliability</code> <pre> <b><i>update_organization_config</i></b> assumes <b><i>sync_status_forward</i></b> is a mapping whose values are mappings and immediately calls <b><i>.values()</i></b> and <b><i>.get()</i></b> on those objects. A list, string, or null mapping value raises an uncaught attribute error, so malformed API input returns a server error instead of a controlled validation response. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The new configuration parser dereferences unvalidated JSON container and mapping types, allowing malformed requests to raise uncaught exceptions. ## Fix Focus Areas - src/sentry/integrations/gitlab/integration.py[361-388] - src/sentry/integrations/api/endpoints/organization_integration_details.py[150-156] ## Recommended Fix Verify that `sync_status_forward` is a mapping and that every value is a mapping with string status fields before calling mapping methods or indexing fields. Raise `IntegrationError` for every invalid shape so the endpoint consistently returns a validation response. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
src/sentry/integrations/gitlab/search.py:83
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 2\. Gitlab issue creation fails for groups <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>handle_search_repositories</i></b> now returns <b><i>path_with_namespace</i></b> as the selected <b><i>project</i></b> value, but <b><i>GitlabIssuesSpec.create_issue</i></b> passes it directly to <b><i>client.create_issue</i></b> and <b><i>client.get_project</i></b>, which interpolate it into <b><i>/projects/{project}</i></b> without quoting. Selecting a group or subgroup project such as <b><i>group/project</i></b> reaches both the issue-creation and project-lookup requests with unescaped slashes, unlike the newly added status-search path that explicitly quotes project paths. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The shared GitLab project autocomplete now returns namespace paths, but the existing issue-creation flow interpolates the selected value into GitLab API paths without URL-encoding it. ## Fix Focus Areas - src/sentry/integrations/gitlab/search.py[78-85] - src/sentry/integrations/gitlab/issues.py[92-115] - src/sentry/integrations/gitlab/client.py[219-241] ## Recommended Fix Ensure every GitLab client operation receiving a project from this endpoint URL-encodes namespace paths before formatting `/projects/{project}` URLs, including both project lookup and issue creation. Preserve numeric project IDs unchanged and avoid double encoding values already encoded by callers; alternatively, use a separate status-mapping search value if preserving raw IDs is preferable. Add a create-issue test using a namespaced autocomplete result. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
src/sentry/integrations/gitlab/integration.py:376
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 3\. Invalid saves erase configured projects <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>update_organization_config</i></b> deletes every existing <b><i>IntegrationExternalProject</i></b> row before validating all replacement status values and completing replacement writes, either of which can raise. An invalid later mapping or database constraint failure therefore leaves the prior configuration absent or partially replaced even though the endpoint catches <b><i>IntegrationError</i></b> and rejects the edit with a 400, without a transaction to restore the rows. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description A rejected status-sync configuration request can delete the existing project mappings or leave them partially replaced because incoming values and database writes are not fully validated and completed before storage is modified. ## Fix Focus Areas - src/sentry/integrations/gitlab/integration.py[361-396] - src/sentry/integrations/api/endpoints/organization_integration_details.py[150-156] - src/sentry/integrations/models/integration_external_project.py[12-23] ## Recommended Fix Validate the complete submitted mapping payload, including all status values and project-path field limits, before deleting any existing rows. Perform the deletion, replacement creation, and organization-integration configuration persistence in a single transaction so any validation or database exception restores the prior mappings instead of leaving them empty or partially replaced. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
src/sentry/integrations/gitlab/integration.py:372
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 5\. Organizations can enable an unreleased sync <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>update_organization_config</i></b> accepts arbitrary <b><i>sync_status_forward</i></b> request data without checking <b><i>check_feature_flag()</i></b>, persists its enablement and mappings, and <b><i>sync_status_outbound</i></b> performs project lookup and GitLab updates while checking only the general issue-sync feature and <b><i>should_sync</i></b>. An administrator can submit the hidden field—or retain an existing enabled setting—while the project-management rollout flag is disabled and still have Sentry status changes update GitLab tickets, despite the UI and inbound handling being gated. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The GitLab project-management rollout flag hides status-sync configuration and stops inbound handling, but direct configuration requests can still enable and persist outbound synchronization, and existing enabled settings can continue causing GitLab updates while the flag is disabled. ## Fix Focus Areas - src/sentry/integrations/gitlab/integration.py[298-344] - src/sentry/integrations/gitlab/integration.py[361-372] - src/sentry/integrations/gitlab/issue_sync.py[170-205] - src/sentry/integrations/gitlab/issue_sync.py[258-273] - src/sentry/integrations/tasks/sync_status_outbound.py[39-77] ## Recommended Fix Reject or ignore `sync_status_forward` updates when `check_feature_flag()` is false, and return before outbound synchronization when the same flag is false so persisted settings cannot activate the feature outside its rollout, matching inbound behavior. Add a test proving that an enabled persisted setting makes no GitLab requests while the rollout flag is disabled. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
PR-level
<h3>PR Summary by Qodo</h3> Add outbound GitLab issue status synchronization <code>✨ Enhancement</code> <code>🧪 Tests</code> <code>🐞 Bug fix</code> <code>🕐 40+ Minutes</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <details> <summary>AI Description</summary> <dl> <dd> <br/> ><pre> >• Adds per-project GitLab mappings for resolved and unresolved Sentry issue statuses. >• Synchronizes linked GitLab issues while skipping missing mappings and redundant transitions. >• Routes webhook refreshes through repository RPC and tests configuration, search, and API behavior. ></pre> </dd> </dl> </details> <details> <summary>Diagram</summary> <dl> <dd> <br/> ```mermaid sequenceDiagram actor Admin as Organization Admin participant Config as GitLab Config participant Mapping as Project Mappings actor Issue as Sentry Issue participant Sync as Status Sync participant GitLab as GitLab API Admin->>Config: Save status mappings Config->>Mapping: Replace project mappings Issue->>Sync: Resolve or unresolve Sync->>Mapping: Load mapped status Mapping-->>Sync: Opened or closed Sync->>GitLab: Read issue state GitLab-->>Sync: Current state alt State differs Sync->>GitLab: Close or reopen end ``` </dd> </dl> </details> <details> <summary>High-Level Assessment</summary> <dl> <dd> <br/> >The following are alternative approaches to this PR: <details> <summary><b>1. Store mappings in integration config JSON</b></summary> <dl> <dd> - ➕ Avoids separate project-mapping database records - ➕ Could save the boolean and mappings atomically in one configuration payload - ➖ Duplicates a persistence concern already represented by IntegrationExternalProject - ➖ Makes project-specific lookup and future metadata expansion less structured </dd> </dl> </details> <details> <summary><b>2. Send transitions without reading current state</b></summary> <dl> <dd> - ➕ Removes one GitLab API request from each synchronization - ➕ Simplifies the runtime call sequence - ➖ Sends unnecessary transition requests when the issue already has the desired state - ➖ Reduces observability of previous state and may produce avoidable GitLab side effects </dd> </dl> </details> >**Recommendation:** Keep the PR&#x27;s IntegrationExternalProject-backed mappings and read-before-transition flow. They reuse the existing project-specific model, support efficient mapping lookup, and avoid redundant external mutations; routing webhook scheduling through the repository service also preserves the silo boundary. </dd> </dl> </details> <details> <summary> Files changed (10) <code> +666 / -34 </code> </summary> <dl> <dd> <br/> <details> <summary>Enhancement (4) <code> +196 / -8 </code></summary> <dl> <dd> <details> <summary>integration.py<code>Add per-project outbound status sync configuration</code> <code>+92/-5</code></summary> <br/> >Add per-project outbound status sync configuration > ><pre> >• Adds a feature-gated choice mapper for selecting GitLab projects and their resolve/unresolve statuses. Validates and persists mappings as IntegrationExternalProject records, and schedules outdated webhook refreshes through the repository service boundary. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-2d720bd6fa142076c64674597f44a95a5edef934e20544c8332346b4912f3b79'>src/sentry/integrations/gitlab/integration.py</a> </details> <details> <summary>issue_sync.py<code>Synchronize Sentry status changes to GitLab</code> <code>+90/-2</code></summary> <br/> >Synchronize Sentry status changes to GitLab > ><pre> >• Implements outbound status synchronization by resolving the configured project mapping, reading the current GitLab issue state, and issuing close or reopen transitions only when needed. Handles malformed keys, missing mappings, invalid states, and API failures with logging or integration errors. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-6262b49b571fb5b4d799c21e0e9162ab01ba35a5525636007e6db2c298169313'>src/sentry/integrations/gitlab/issue_sync.py</a> </details> <details> <summary>search.py<code>Return GitLab namespace paths from project search</code> <code>+4/-1</code></summary> <br/> >Return GitLab namespace paths from project search > ><pre> >• Changes project search option values from numeric GitLab IDs to path-with-namespace identifiers so configuration mappings match linked issue keys and API paths. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-2850a264189b2d660d8ae289c202cf2a50b76062b3c1dfd861dc539587465456'>src/sentry/integrations/gitlab/search.py</a> </details> <details> <summary>types.py<code>Define supported GitLab issue statuses</code> <code>+10/-0</code></summary> <br/> >Define supported GitLab issue statuses > ><pre> >• Adds an opened/closed status enum with dropdown-ready choices for status mapping configuration. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-4a4f3745505ef469ea1f8d0a8e9b6b597d568292aca0e96a58da67c7a23f954b'>src/sentry/integrations/gitlab/types.py</a> </details> </dd> </dl> </details> <details> <summary>Bug fix (1) <code> +1 / -1 </code></summary> <dl> <dd> <details> <summary>client.py<code>Encode project identifiers in issue-search paths</code> <code>+1/-1</code></summary> <br/> >Encode project identifiers in issue-search paths > ><pre> >• URL-encodes GitLab project identifiers before formatting project issue search endpoints, supporting namespace paths and other reserved characters safely. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-6dcf45e6e5f6584168e2f4a6b225b6ba0241d47884296d4fabb1d920e79fe8e5'>src/sentry/integrations/gitlab/client.py</a> </details> </dd> </dl> </details> <details> <summary>Tests (3) <code> +444 / -24 </code></summary> <dl> <dd> <details> <summary>test_organization_integration_details.py<code>Mock repository webhook scheduling in config endpoint test</code> <code>+3/-1</code></summary> <br/> >Mock repository webhook scheduling in config endpoint test > ><pre> >• Updates the organization integration configuration test to patch the new repository service scheduling boundary instead of the task import. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-cafb8825fa5f14151b6c0cba26886a8772acd7896b94a2d1bdd470a824b1accd'>tests/sentry/integrations/api/endpoints/test_organization_integration_details.py</a> </details> <details> <summary>test_integration.py<code>Cover GitLab status mappings and outbound transitions</code> <code>+437/-19</code></summary> <br/> >Cover GitLab status mappings and outbound transitions > ><pre> >• Adds coverage for mapping persistence, config serialization, required and valid statuses, resolve and unresolve transitions, no-op behavior, malformed keys, and API errors. Existing webhook tests now assert calls through the repository service. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-b5beda994bbef71e21ec9b0698fd856aacb816c7ad6eab27041cff9707116b48'>tests/sentry/integrations/gitlab/test_integration.py</a> </details> <details> <summary>test_search.py<code>Expect namespace paths in GitLab project results</code> <code>+4/-4</code></summary> <br/> >Expect namespace paths in GitLab project results > ><pre> >• Updates project search assertions to expect path-with-namespace values rather than numeric project IDs, including paginated results. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-c8f8bffad1b92a2a1cc761810642da0565a67f405fe7877f9e4831e1cbfe6ac7'>tests/sentry/integrations/gitlab/test_search.py</a> </details> </dd> </dl> </details> <details> <summary>Other (2) <code> +25 / -1 </code></summary> <dl> <dd> <details> <summary>impl.py<code>Implement GitLab webhook scheduling service method</code> <code>+12/-1</code></summary> <br/> >Implement GitLab webhook scheduling service method > ><pre> >• Adds the repository service implementation that dispatches the existing asynchronous GitLab project webhook update task. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-89b1aa3acd533602638b6a9105c02589305fe58362228aaf6cda370cb4a2d909'>src/sentry/integrations/services/repository/impl.py</a> </details> <details> <summary>service.py<code>Expose silo-aware GitLab webhook scheduling</code> <code>+13/-0</code></summary> <br/> >Expose silo-aware GitLab webhook scheduling > ><pre> >• Defines a cell-routed repository service method for scheduling GitLab project webhook refreshes by organization and integration. ></pre> > ><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-62277d9f6cc008cd5cc4e175601630734e08029754b77ffb01768c32d0daa810'>src/sentry/integrations/services/repository/service.py</a> </details> </dd> </dl> </details> </dd> </dl> </details>
PR-level
<h3>Code Review by Qodo</h3> <code>🐞 Bugs (5)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <br/> <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> <details> <summary> 1. Linked issues never sync their status <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>sync_status_outbound</i></b> passes <b><i>external_issue.key</i></b> to <b><i>split_external_issue_key</i></b>, which requires a >domain prefix that the normal create and link flows do not store. Issues linked through those flows >use <b><i>path_with_namespace#iid</i></b>, so they return through the invalid-key branch before mapping lookup >or any GitLab request. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[src/sentry/integrations/gitlab/issue_sync.py[R172-175]](https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-6262b49b571fb5b4d799c21e0e9162ab01ba35a5525636007e6db2c298169313R172-R175)</code> > >```diff >+ project_path, issue_iid = self.split_external_issue_key(external_issue.key) >+ >+ if not project_path or not issue_iid: >+ logger.warning( >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The parser unconditionally splits on a colon, while both normal issue flows explicitly return keys >without one; the new outbound method exits immediately when that parser fails. ></pre> > > <code>[src/sentry/integrations/gitlab/issue_sync.py[39-59]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issue_sync.py/#L39-L59)</code> > <code>[src/sentry/integrations/gitlab/issue_sync.py[172-201]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issue_sync.py/#L172-L201)</code> > <code>[src/sentry/integrations/gitlab/issues.py[115-123]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issues.py/#L115-L123)</code> > <code>[src/sentry/integrations/gitlab/issues.py[185-208]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issues.py/#L185-L208)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Outbound status synchronization rejects the domain-less external issue keys produced by normal GitLab issue creation and linking. > >## Fix Focus Areas >- src/sentry/integrations/gitlab/issue_sync.py[39-59] >- src/sentry/integrations/gitlab/issue_sync.py[170-182] >- src/sentry/integrations/gitlab/issues.py[115-123] >- src/sentry/integrations/gitlab/issues.py[201-208] > >## Recommended Fix >Update external-key parsing to support both `domain:path#iid` and `path#iid`, then add outbound-sync tests using keys returned by the actual create and link flows rather than only domain-prefixed fixtures. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 2. GitLab issue creation fails for groups <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>handle_search_repositories</i></b> now returns <b><i>path_with_namespace</i></b> as the selected <b><i>project</i></b> value, but ><b><i>GitlabIssuesSpec.create_issue</i></b> passes it directly to <b><i>client.create_issue</i></b> and ><b><i>client.get_project</i></b>, which interpolate it into <b><i>/projects/{project}</i></b> without quoting. Selecting a >group or subgroup project such as <b><i>group/project</i></b> reaches both the issue-creation and project-lookup >requests with unescaped slashes, unlike the newly added status-search path that explicitly quotes >project paths. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[src/sentry/integrations/gitlab/search.py[R80-83]](https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-2850a264189b2d660d8ae289c202cf2a50b76062b3c1dfd861dc539587465456R80-R83)</code> > >```diff >+ { >+ "label": project["name_with_namespace"], >+ "value": project["path_with_namespace"], >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The changed search endpoint is the autocomplete source used by the create-issue form, which forwards >the selected <b><i>project</i></b> value directly to the create and lookup client methods. Those methods format >the value into a single URL segment without quoting it, while another changed GitLab client method >explicitly documents and implements quoting for the same kind of slash-containing namespace path. ></pre> > > <code>[src/sentry/integrations/gitlab/issues.py[74-88]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issues.py/#L74-L88)</code> > <code>[src/sentry/integrations/gitlab/issues.py[92-122]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issues.py/#L92-L122)</code> > <code>[src/sentry/integrations/gitlab/client.py[219-241]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/client.py/#L219-L241)</code> > <code>[src/sentry/integrations/gitlab/client.py[465-472]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/client.py/#L465-L472)</code> > <code>[src/sentry/integrations/gitlab/client.py[60-68]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/client.py/#L60-L68)</code> > <code>[src/sentry/integrations/gitlab/issues.py[65-88]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issues.py/#L65-L88)</code> > <code>[src/sentry/integrations/gitlab/issues.py[92-115]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issues.py/#L92-L115)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The shared GitLab project autocomplete now returns namespace paths, but the existing issue-creation flow interpolates the selected value into GitLab API paths without URL-encoding it. > >## Fix Focus Areas >- src/sentry/integrations/gitlab/search.py[78-85] >- src/sentry/integrations/gitlab/issues.py[92-115] >- src/sentry/integrations/gitlab/client.py[219-241] > >## Recommended Fix >Ensure every GitLab client operation receiving a project from this endpoint URL-encodes namespace paths before formatting `/projects/{project}` URLs, including both project lookup and issue creation. Preserve numeric project IDs unchanged and avoid double encoding values already encoded by callers; alternatively, use a separate status-mapping search value if preserving raw IDs is preferable. Add a create-issue test using a namespaced autocomplete result. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 3. Invalid saves erase configured projects <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>update_organization_config</i></b> deletes every existing <b><i>IntegrationExternalProject</i></b> row before >validating all replacement status values and completing replacement writes, either of which can >raise. An invalid later mapping or database constraint failure therefore leaves the prior >configuration absent or partially replaced even though the endpoint catches <b><i>IntegrationError</i></b> and >rejects the edit with a 400, without a transaction to restore the rows. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[src/sentry/integrations/gitlab/integration.py[R374-376]](https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-2d720bd6fa142076c64674597f44a95a5edef934e20544c8332346b4912f3b79R374-R376)</code> > >```diff >+ IntegrationExternalProject.objects.filter( >+ organization_integration_id=self.org_integration.id >+ ).delete() >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The cited implementation checks only for missing fields before the bulk deletion, then validates >status values and creates replacement rows one at a time. Those creations are also subject to model >length and uniqueness constraints, so validation or persistence can fail after destructive changes; >the endpoint converts <b><i>IntegrationError</i></b> into an error response rather than rolling back, while >configuration serialization reads these rows as the persisted status mappings. ></pre> > > <code>[src/sentry/integrations/gitlab/integration.py[361-396]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/integration.py/#L361-L396)</code> > <code>[src/sentry/integrations/api/endpoints/organization_integration_details.py[150-156]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/api/endpoints/organization_integration_details.py/#L150-L156)</code> > <code>[src/sentry/integrations/gitlab/issue_sync.py[275-288]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issue_sync.py/#L275-L288)</code> > <code>[src/sentry/integrations/models/integration_external_project.py[8-23]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/models/integration_external_project.py/#L8-L23)</code> > <code>[src/sentry/integrations/models/integration_external_project.py[12-23]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/models/integration_external_project.py/#L12-L23)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >A rejected status-sync configuration request can delete the existing project mappings or leave them partially replaced because incoming values and database writes are not fully validated and completed before storage is modified. > >## Fix Focus Areas >- src/sentry/integrations/gitlab/integration.py[361-396] >- src/sentry/integrations/api/endpoints/organization_integration_details.py[150-156] >- src/sentry/integrations/models/integration_external_project.py[12-23] > >## Recommended Fix >Validate the complete submitted mapping payload, including all status values and project-path field limits, before deleting any existing rows. Perform the deletion, replacement creation, and organization-integration configuration persistence in a single transaction so any validation or database exception restores the prior mappings instead of leaving them empty or partially replaced. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <br/> <img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> <details> <summary> 4. Malformed settings return server errors <code>🐞 Bug</code> <code>☼ Reliability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>update_organization_config</i></b> assumes <b><i>sync_status_forward</i></b> is a mapping whose values are mappings >and immediately calls <b><i>.values()</i></b> and <b><i>.get()</i></b> on those objects. A list, string, or null mapping >value raises an uncaught attribute error, so malformed API input returns a server error instead of a >controlled validation response. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[src/sentry/integrations/gitlab/integration.py[R365-368]](https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-2d720bd6fa142076c64674597f44a95a5edef934e20544c8332346b4912f3b79R365-R368)</code> > >```diff >+ # Validate that all mappings have both statuses >+ if any( >+ not mapping.get("on_unresolve") or not mapping.get("on_resolve") >+ for mapping in project_mappings.values() >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The new code operates directly on arbitrary request data without checking its shape, while the >endpoint catches only integration and API errors rather than the resulting attribute or type errors. ></pre> > > <code>[src/sentry/integrations/gitlab/integration.py[361-388]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/integration.py/#L361-L388)</code> > <code>[src/sentry/integrations/api/endpoints/organization_integration_details.py[150-156]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/api/endpoints/organization_integration_details.py/#L150-L156)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The new configuration parser dereferences unvalidated JSON container and mapping types, allowing malformed requests to raise uncaught exceptions. > >## Fix Focus Areas >- src/sentry/integrations/gitlab/integration.py[361-388] >- src/sentry/integrations/api/endpoints/organization_integration_details.py[150-156] > >## Recommended Fix >Verify that `sync_status_forward` is a mapping and that every value is a mapping with string status fields before calling mapping methods or indexing fields. Raise `IntegrationError` for every invalid shape so the endpoint consistently returns a validation response. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 5. Organizations can enable an unreleased sync <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>update_organization_config</i></b> accepts arbitrary <b><i>sync_status_forward</i></b> request data without checking ><b><i>check_feature_flag()</i></b>, persists its enablement and mappings, and <b><i>sync_status_outbound</i></b> performs >project lookup and GitLab updates while checking only the general issue-sync feature and ><b><i>should_sync</i></b>. An administrator can submit the hidden field—or retain an existing enabled >setting—while the project-management rollout flag is disabled and still have Sentry status changes >update GitLab tickets, despite the UI and inbound handling being gated. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[src/sentry/integrations/gitlab/integration.py[R361-372]](https://github.com/drape-io/crbench-qodo-2026-09/pull/67/files#diff-2d720bd6fa142076c64674597f44a95a5edef934e20544c8332346b4912f3b79R361-R372)</code> > >```diff >+ # Handle status sync configuration >+ if "sync_status_forward" in data: >+ project_mappings = data.pop("sync_status_forward") >+ >+ # Validate that all mappings have both statuses >+ if any( >+ not mapping.get("on_unresolve") or not mapping.get("on_resolve") >+ for mapping in project_mappings.values() >+ ): >+ raise IntegrationError("Resolve and unresolve status are required.") >+ >+ data["sync_status_forward"] = bool(project_mappings) >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The citations show that the configuration UI is added only when the GitLab project-management flag >is enabled and inbound status handling explicitly checks the same flag, while the update branch >accepts <b><i>sync_status_forward</i></b> unconditionally. They also show that task dispatch evaluates only the >general issue-sync feature and persisted configuration before invoking the outbound implementation, >which performs the GitLab work without calling <b><i>check_feature_flag()</i></b>. ></pre> > > <code>[src/sentry/integrations/gitlab/integration.py[298-344]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/integration.py/#L298-L344)</code> > <code>[src/sentry/integrations/gitlab/integration.py[361-396]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/integration.py/#L361-L396)</code> > <code>[src/sentry/integrations/gitlab/issue_sync.py[31-37]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issue_sync.py/#L31-L37)</code> > <code>[src/sentry/integrations/mixins/issues.py[416-428]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/mixins/issues.py/#L416-L428)</code> > <code>[src/sentry/integrations/tasks/sync_status_outbound.py[39-77]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/tasks/sync_status_outbound.py/#L39-L77)</code> > <code>[src/sentry/integrations/gitlab/integration.py[296-344]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/integration.py/#L296-L344)</code> > <code>[src/sentry/integrations/gitlab/issue_sync.py[170-205]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issue_sync.py/#L170-L205)</code> > <code>[src/sentry/integrations/gitlab/issue_sync.py[258-273]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/gitlab/issue_sync.py/#L258-L273)</code> > <code>[src/sentry/integrations/tasks/sync_status_outbound.py[38-76]](https://github.com/drape-io/crbench-qodo-2026-09/blob/62529426bd970516f38d2e4cf1f53cb40ee9eef5/src/sentry/integrations/tasks/sync_status_outbound.py/#L38-L76)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The GitLab project-management rollout flag hides status-sync configuration and stops inbound handling, but direct configuration requests can still enable and persist outbound synchronization, and existing enabled settings can continue causing GitLab updates while the flag is disabled. > >## Fix Focus Areas >- src/sentry/integrations/gitlab/integration.py[298-344] >- src/sentry/integrations/gitlab/integration.py[361-372] >- src/sentry/integrations/gitlab/issue_sync.py[170-205] >- src/sentry/integrations/gitlab/issue_sync.py[258-273] >- src/sentry/integrations/tasks/sync_status_outbound.py[39-77] > >## Recommended Fix >Reject or ignore `sync_status_forward` updates when `check_feature_flag()` is false, and return before outbound synchronization when the same flag is false so persisted settings cannot activate the feature outside its rollout, matching inbound behavior. Add a test proving that an enabled persisted setting makes no GitLab requests while the rollout flag is disabled. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-context:start --> <details><summary><strong>Context sources</strong></summary> <div>Review mode: <code>🧠 Deep</code>: This is a broad, behavior-changing integration feature spanning configuration persistence, GitLab API status transitions, service/RPC boundaries, and many independent paths, creating substantial opportunity for multiple subtle defects.</div> <!-- qodo-context:end --> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:start --> <details> <summary><strong>Tip of the day</strong></summary> <br/> <pre>💡 Did you know, you can reply &#x27;qodo&#x27; on any finding to push back, ask questions, or dig deeper</pre> <a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:end --> <!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/62529426bd970516f38d2e4cf1f53cb40ee9eef5 --> <a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>