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

Skip to content

Conversation

@andyfeller
Copy link
Member

@andyfeller andyfeller commented Dec 22, 2025

Relates #12325

This commit applies familiar conditional protections around v2 project items to avoid panics including:

for _, node := range resp.Assignments.Nodes {
if node == nil {
continue // likely due to FORBIDDEN results
}
switch node.Type {
case "Issue":
issues = append(issues, *node)
case "PullRequest":
prs = append(prs, *node)
default:
return fmt.Errorf("unknown Assignments type: %q", node.Type)
}
}
for _, node := range resp.ReviewRequested.Nodes {
if node == nil {
continue // likely due to FORBIDDEN results
}
reviewRequested = append(reviewRequested, *node)
}

cli/pkg/cmd/pr/view/view.go

Lines 459 to 468 in baf6299

for _, project := range pr.ProjectCards.Nodes {
if project == nil {
continue
}
colName := project.Column.Name
if colName == "" {
colName = "Awaiting triage"
}
projectNames = append(projectNames, fmt.Sprintf("%s (%s)", project.Project.Name, colName))
}

This commit applies familiar conditional protections around v2 project items to avoid panics as mentioned in #12325.
@andyfeller
Copy link
Member Author

Sorry, I didn't see #12324

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds null safety guards to prevent panics when processing v2 project items that may contain null entries in their nodes array. This addresses issue #12325 where null project items from the GraphQL API could cause runtime panics.

Key changes:

  • Added null checks in ProjectsV2ItemsForIssue and ProjectsV2ItemsForPullRequest functions to skip null nodes
  • Added comprehensive test cases for both issue and pull request scenarios with null project items

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
api/queries_projects_v2.go Added nil checks before processing project item nodes in both issue and pull request fetching functions
api/queries_projects_v2_test.go Added test cases to verify null project items are gracefully skipped without errors

The changes are well-implemented and consistent with existing patterns in the codebase (e.g., similar null handling in pkg/cmd/status/status.go lines 473-492 and pkg/cmd/pr/view/view.go lines 459-468). The tests appropriately verify the new behavior, and the fix is applied at the correct layer (API) to protect all downstream consumers from null pointer panics.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants