Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't log request cancellation as internal errors in the Github APIs #5976

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions admin/server/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ func (s *Server) GetGithubUserStatus(ctx context.Context, req *adminv1.GetGithub
// List all the private organizations for the authenticated user
orgs, _, err := client.Organizations.List(ctx, "", nil)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get user organizations: %s", err.Error())
return nil, fmt.Errorf("failed to get user organizations: %w", err)
}
// List all the public organizations for the authenticated user
publicOrgs, _, err := client.Organizations.List(ctx, user.GithubUsername, nil)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get user organizations: %s", err.Error())
return nil, fmt.Errorf("failed to get user organizations: %w", err)
}

orgs = append(orgs, publicOrgs...)
Expand All @@ -141,7 +141,7 @@ func (s *Server) GetGithubUserStatus(ctx context.Context, req *adminv1.GetGithub
orgInstallationPermission[org.GetLogin()] = adminv1.GithubPermission_GITHUB_PERMISSION_UNSPECIFIED
continue
}
return nil, status.Errorf(codes.Internal, "failed to get organization installation: %s", err.Error())
return nil, fmt.Errorf("failed to get organization installation: %w", err)
}
permission := adminv1.GithubPermission_GITHUB_PERMISSION_UNSPECIFIED
// older git app would ask for Contents=read permission whereas new one asks for Contents=write and && Administration=write
Expand Down Expand Up @@ -222,7 +222,7 @@ func (s *Server) GetGithubRepoStatus(ctx context.Context, req *adminv1.GetGithub
}
return res, nil
}
return nil, status.Error(codes.Internal, err.Error())
return nil, err
}

res := &adminv1.GetGithubRepoStatusResponse{
Expand Down Expand Up @@ -251,7 +251,7 @@ func (s *Server) ListGithubUserRepos(ctx context.Context, req *adminv1.ListGithu

token, refreshToken, err := s.userAccessToken(ctx, user.GithubRefreshToken)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
return nil, err
}

// refresh token changes after using it for getting a new token
Expand All @@ -274,7 +274,7 @@ func (s *Server) ListGithubUserRepos(ctx context.Context, req *adminv1.ListGithu
// use a client with user's token to get installations
repos, err := s.fetchReposForUser(ctx, client)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
return nil, err
}

return &adminv1.ListGithubUserReposResponse{
Expand Down Expand Up @@ -310,7 +310,7 @@ func (s *Server) ConnectProjectToGithub(ctx context.Context, req *adminv1.Connec

token, refreshToken, err := s.userAccessToken(ctx, user.GithubRefreshToken)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
return nil, err
}

// refresh token changes after using it for getting a new token
Expand Down Expand Up @@ -364,7 +364,7 @@ func (s *Server) ConnectProjectToGithub(ctx context.Context, req *adminv1.Connec

org, err := s.admin.DB.FindOrganization(ctx, proj.OrganizationID)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
return nil, err
}

_, err = s.UpdateProject(ctx, &adminv1.UpdateProjectRequest{
Expand All @@ -375,7 +375,7 @@ func (s *Server) ConnectProjectToGithub(ctx context.Context, req *adminv1.Connec
Subpath: &req.Subpath,
})
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
return nil, err
}

return &adminv1.ConnectProjectToGithubResponse{}, nil
Expand Down
Loading