Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit ca253c1

Browse files
authored
fix: Add missing service GQL error defn (#1123)
1 parent 54aacf3 commit ca253c1

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

graphql_api/tests/test_owner.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
from billing.helpers import mock_all_plans_and_tiers
2727
from codecov.commands.exceptions import (
28-
MissingService,
2928
UnauthorizedGuestAccess,
3029
)
3130
from codecov_auth.models import GithubAppInstallation, OwnerProfile
@@ -708,7 +707,6 @@ def test_owner_query_with_no_service(self):
708707

709708
res = self.gql_request(query, provider="", with_errors=True)
710709

711-
assert res["errors"][0]["message"] == MissingService.message
712710
assert res["data"]["owner"] is None
713711

714712
def test_owner_query_with_private_repos(self):
@@ -1195,3 +1193,19 @@ def test_fetch_available_plans_is_enterprise_plan(self):
11951193
]
11961194
}
11971195
}
1196+
1197+
def test_fetch_owner_with_no_service(self):
1198+
current_org = OwnerFactory(
1199+
username="random-plan-user",
1200+
service="github",
1201+
plan=PlanName.BASIC_PLAN_NAME.value,
1202+
)
1203+
1204+
query = """{
1205+
owner(username: "%s") {
1206+
username
1207+
}
1208+
}
1209+
""" % (current_org.username)
1210+
data = self.gql_request(query, owner=current_org, provider="", with_errors=True)
1211+
assert data == {"data": {"owner": None}}

graphql_api/types/errors/errors.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ type ProviderError implements ResolverError {
3737
type OwnerNotActivatedError implements ResolverError {
3838
message: String!
3939
}
40+
41+
type MissingService implements ResolverError {
42+
message: String!
43+
}

graphql_api/types/mutation/update_default_organization/update_default_organization.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
union UpdateDefaultOrganizationError = UnauthenticatedError | ValidationError
1+
union UpdateDefaultOrganizationError = UnauthenticatedError | ValidationError | MissingService
22

33
type UpdateDefaultOrganizationPayload {
44
error: UpdateDefaultOrganizationError

graphql_api/types/query/query.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ async def resolve_owner(
4646
configure_sentry_scope(query_name(info))
4747

4848
service = info.context["service"]
49+
if not service:
50+
return None
51+
4952
user = info.context["request"].current_owner or info.context["request"].user
5053

5154
if settings.IS_ENTERPRISE and settings.GUEST_ACCESS is False:

0 commit comments

Comments
 (0)