diff --git a/pkg/querier/vcs/client/github.go b/pkg/querier/vcs/client/github.go index 670e0131be..ca307d89a8 100644 --- a/pkg/querier/vcs/client/github.go +++ b/pkg/querier/vcs/client/github.go @@ -12,6 +12,7 @@ import ( "golang.org/x/oauth2" vcsv1 "github.com/grafana/pyroscope/api/gen/proto/go/vcs/v1" + "github.com/grafana/pyroscope/pkg/util/connectgrpc" ) // GithubClient returns a github client. @@ -28,6 +29,11 @@ type githubClient struct { func (gh *githubClient) GetCommit(ctx context.Context, owner, repo, ref string) (*vcsv1.GetCommitResponse, error) { commit, _, err := gh.client.Repositories.GetCommit(ctx, owner, repo, ref, nil) if err != nil { + var githubErr *github.ErrorResponse + if errors.As(err, &githubErr) { + code := connectgrpc.HTTPToCode(int32(githubErr.Response.StatusCode)) + return nil, connect.NewError(code, err) + } return nil, err } diff --git a/pkg/querier/vcs/service.go b/pkg/querier/vcs/service.go index 5ee3c7fba6..4232eabf10 100644 --- a/pkg/querier/vcs/service.go +++ b/pkg/querier/vcs/service.go @@ -199,7 +199,7 @@ func (q *Service) GetCommit(ctx context.Context, req *connect.Request[vcsv1.GetC commit, err := q.tryGetCommit(ctx, ghClient, owner, repo, ref) if err != nil { - return nil, client.MapErrorToConnectCode(err) + return nil, err } return connect.NewResponse(commit), nil