Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/queries_projects_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func ProjectsV2ItemsForIssue(client *Client, repo ghrepo.Interface, issue *Issue
return err
}
for _, projectItemNode := range query.Repository.Issue.ProjectItems.Nodes {
if projectItemNode == nil {
continue
}
items.Nodes = append(items.Nodes, &ProjectV2Item{
ID: projectItemNode.ID,
Project: ProjectV2ItemProject{
Expand Down Expand Up @@ -175,6 +178,9 @@ func ProjectsV2ItemsForPullRequest(client *Client, repo ghrepo.Interface, pr *Pu
}

for _, projectItemNode := range query.Repository.PullRequest.ProjectItems.Nodes {
if projectItemNode == nil {
continue
}
items.Nodes = append(items.Nodes, &ProjectV2Item{
ID: projectItemNode.ID,
Project: ProjectV2ItemProject{
Expand Down
22 changes: 22 additions & 0 deletions api/queries_projects_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ func TestProjectsV2ItemsForIssue(t *testing.T) {
},
expectError: true,
},
{
name: "skips null project items for issue",
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.GraphQL(`query IssueProjectItems\b`),
httpmock.GraphQLQuery(`{"data":{"repository":{"issue":{"projectItems":{"totalCount":1,"nodes":[null]}}}}}`,
func(query string, inputs map[string]interface{}) {}),
)
},
expectItems: ProjectItems{},
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -186,6 +197,17 @@ func TestProjectsV2ItemsForPullRequest(t *testing.T) {
},
expectError: true,
},
{
name: "skips null project items for pull request",
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.GraphQL(`query PullRequestProjectItems\b`),
httpmock.GraphQLQuery(`{"data":{"repository":{"pullRequest":{"projectItems":{"totalCount":1,"nodes":[null]}}}}}`,
func(query string, inputs map[string]interface{}) {}),
)
},
expectItems: ProjectItems{},
},
{
name: "retrieves project items that have status columns",
httpStubs: func(reg *httpmock.Registry) {
Expand Down
Loading