Skip to content

Commit 510aa8a

Browse files
add error if user tries to access multi org without valid feature
1 parent 48b29d1 commit 510aa8a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/sentry/integrations/github/integration.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ class GitHubInstallationError(StrEnum):
762762
USER_MISMATCH = "Authenticated user is not the same as who installed the app."
763763
MISSING_INTEGRATION = "Integration does not exist."
764764
INVALID_INSTALLATION = "User does not have access to given installation"
765+
FEATURE_NOT_AVAILABLE = "Organization does not have access to this feature"
765766

766767

767768
def record_event(event: IntegrationPipelineViewType):
@@ -927,9 +928,18 @@ def dispatch(self, request: HttpRequest, pipeline: Pipeline) -> HttpResponseBase
927928
)
928929

929930
if chosen_installation_id := request.GET.get("chosen_installation_id"):
930-
if chosen_installation_id == "-1" or not has_scm_multi_org:
931+
932+
if chosen_installation_id == "-1":
931933
return pipeline.next_step()
932934

935+
if not has_scm_multi_org:
936+
lifecycle.record_failure(GitHubInstallationError.FEATURE_NOT_AVAILABLE)
937+
return error(
938+
request,
939+
self.active_user_organization,
940+
error_short=GitHubInstallationError.FEATURE_NOT_AVAILABLE,
941+
)
942+
933943
# Verify that the given GH installation belongs to the person installing the pipeline
934944
installation_ids = [
935945
installation["installation_id"] for installation in installation_info

0 commit comments

Comments
 (0)