Skip to content

Commit 4a106c1

Browse files
committed
fix: prevent panic when processing null project items
The GraphQL API can return `null` nodes in the `projectItems` connection, causing a runtime panic (nil pointer dereference) when the CLI attempted to access fields on these nil nodes. This crash occurs even with personal access tokens with full read access. Adds a check to safely skip `nil` nodes in `ProjectsV2ItemsForIssue` and `ProjectsV2ItemsForPullRequest`. Signed-off-by: Chris Henzie <chrishenzie@google.com>
1 parent 51dfeea commit 4a106c1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

api/queries_projects_v2.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ func ProjectsV2ItemsForIssue(client *Client, repo ghrepo.Interface, issue *Issue
106106
return err
107107
}
108108
for _, projectItemNode := range query.Repository.Issue.ProjectItems.Nodes {
109+
if projectItemNode == nil {
110+
continue
111+
}
109112
items.Nodes = append(items.Nodes, &ProjectV2Item{
110113
ID: projectItemNode.ID,
111114
Project: ProjectV2ItemProject{
@@ -175,6 +178,9 @@ func ProjectsV2ItemsForPullRequest(client *Client, repo ghrepo.Interface, pr *Pu
175178
}
176179

177180
for _, projectItemNode := range query.Repository.PullRequest.ProjectItems.Nodes {
181+
if projectItemNode == nil {
182+
continue
183+
}
178184
items.Nodes = append(items.Nodes, &ProjectV2Item{
179185
ID: projectItemNode.ID,
180186
Project: ProjectV2ItemProject{

0 commit comments

Comments
 (0)