Skip to content

Commit 2c8823d

Browse files
committed
add http resp code checking for getProjectItem
1 parent fdc5490 commit 2c8823d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/github/projects.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,14 @@ func getProjectItem(ctx context.Context, client *github.Client, owner, ownerType
16291629
}
16301630
defer func() { _ = resp.Body.Close() }()
16311631

1632+
if resp.StatusCode != http.StatusOK {
1633+
body, err := io.ReadAll(resp.Body)
1634+
if err != nil {
1635+
return nil, nil, fmt.Errorf("failed to read response body: %w", err)
1636+
}
1637+
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get project item", resp, body), nil, nil
1638+
}
1639+
16321640
r, err := json.Marshal(projectItem)
16331641
if err != nil {
16341642
return nil, nil, fmt.Errorf("failed to marshal response: %w", err)

0 commit comments

Comments
 (0)