Add status check before deserializing runner-registration response (#2699)

This commit is contained in:
Nikola Jokic
2023-07-05 21:09:07 +02:00
committed by GitHub
parent 6fe8008640
commit fde1893494
3 changed files with 71 additions and 8 deletions
+10
View File
@@ -921,6 +921,16 @@ func (c *Client) getActionsServiceAdminConnection(ctx context.Context, rt *regis
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
registrationErr := fmt.Errorf("unexpected response from Actions service during registration call: %v", resp.StatusCode)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("%v - %v", registrationErr, err)
}
return nil, fmt.Errorf("%v - %v", registrationErr, string(body))
}
var actionsServiceAdminConnection *ActionsServiceAdminConnection
if err := json.NewDecoder(resp.Body).Decode(&actionsServiceAdminConnection); err != nil {
return nil, err