Skip to content

Commit eaa53a2

Browse files
authored
Return error when GH configuration is missing (#3334)
1 parent 0c63617 commit eaa53a2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pkg/querier/vcs/github.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package vcs
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"io"
78
"net/http"
@@ -148,3 +149,21 @@ func githubAuthTokenFromFormURLEncoded(values url.Values) (*githubAuthToken, err
148149

149150
return token, nil
150151
}
152+
153+
func isGitHubIntegrationConfigured() error {
154+
var errs []error
155+
156+
if githubAppClientID == "" {
157+
errs = append(errs, fmt.Errorf("missing GITHUB_CLIENT_ID environment variable"))
158+
}
159+
160+
if githubAppClientSecret == "" {
161+
errs = append(errs, fmt.Errorf("missing GITHUB_CLIENT_SECRET environment variable"))
162+
}
163+
164+
if len(githubSessionSecret) == 0 {
165+
errs = append(errs, fmt.Errorf("missing GITHUB_SESSION_SECRET environment variable"))
166+
}
167+
168+
return errors.Join(errs...)
169+
}

pkg/querier/vcs/service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ func New(logger log.Logger, reg prometheus.Registerer) *Service {
3737
}
3838

3939
func (q *Service) GithubApp(ctx context.Context, req *connect.Request[vcsv1.GithubAppRequest]) (*connect.Response[vcsv1.GithubAppResponse], error) {
40+
err := isGitHubIntegrationConfigured()
41+
if err != nil {
42+
q.logger.Log("err", err, "msg", "GitHub integration is not configured")
43+
return nil, connect.NewError(connect.CodeUnimplemented, fmt.Errorf("GitHub integration is not configured"))
44+
}
45+
4046
return connect.NewResponse(&vcsv1.GithubAppResponse{
4147
ClientID: githubAppClientID,
4248
}), nil

0 commit comments

Comments
 (0)