Skip to content

Commit b7a0ecd

Browse files
fix(api): Add UnauthenticatedError to upload token error union
The RegenerateRepositoryUploadTokenError union was missing UnauthenticatedError, causing a GraphQL runtime error when unauthenticated requests hit the resolver. Add the missing type to match the sibling RegenerateRepositoryTokenError union and add a test for the unauthenticated case. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4bf8d00 commit b7a0ecd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

apps/codecov-api/graphql_api/tests/mutation/test_regenerate_repository_upload_token.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ def setUp(self):
2424
self.repo = RepositoryFactory(author=self.org, name="gazebo", private=False)
2525
self.old_repo_token = self.repo.upload_token
2626

27+
def test_when_unauthenticated(self):
28+
data = self.gql_request(
29+
query,
30+
variables={"input": {"repoName": "gazebo", "owner": "codecov"}},
31+
)
32+
assert (
33+
data["regenerateRepositoryUploadToken"]["error"]["__typename"]
34+
== "UnauthenticatedError"
35+
)
36+
2737
def test_when_unauthorized_user_not_part_of_org(self):
2838
random_user = OwnerFactory()
2939
data = self.gql_request(

apps/codecov-api/graphql_api/types/mutation/regenerate_repository_upload_token/regenerate_repository_upload_token.graphql

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

33
type RegenerateRepositoryUploadTokenPayload {
44
token: String

0 commit comments

Comments
 (0)