Skip to content

Commit

Permalink
fix(github): made sure GraphQL requests, with non-GraphQL errors is r…
Browse files Browse the repository at this point in the history
…eported properly (lindell#301)
  • Loading branch information
lindell authored Nov 10, 2022
1 parent cfc2861 commit d7e1fda
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/scm/github/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (g *Github) makeGraphQLRequest(ctx context.Context, query string, data inte
Errors []struct {
Message string `json:"message"`
} `json:"errors"`
Message string `json:"message"`
}{}

if err := json.NewDecoder(resp.Body).Decode(&resultData); err != nil {
Expand All @@ -67,6 +68,10 @@ func (g *Github) makeGraphQLRequest(ctx context.Context, query string, data inte
)
}

if resp.StatusCode >= 400 {
return errors.Errorf("could not make GitHub GraphQL request: %s", resultData.Message)
}

if err := json.Unmarshal(resultData.Data, res); err != nil {
return err
}
Expand Down

0 comments on commit d7e1fda

Please sign in to comment.