Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when login for github_organization doesn't exist closes #71 #75

Merged
merged 1 commit into from
Oct 20, 2021
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
9 changes: 9 additions & 0 deletions github/table_github_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func getOrganizationDetail(ctx context.Context, d *plugin.QueryData, h *plugin.H

if h.Item != nil {
org := h.Item.(*github.Organization)
// Check the null value for hydrated item, while accessing the inner level property of the null value it this throwing panic error
if org == nil {
return nil, nil
}
login = *org.Login
} else {
login = d.KeyColumnQuals["login"].GetStringValue()
Expand Down Expand Up @@ -134,6 +138,11 @@ func tableGitHubOrganizationMembersGet(ctx context.Context, d *plugin.QueryData,
logger := plugin.Logger(ctx)

org := h.Item.(*github.Organization)

// Check the null value for hydrated item, while accessing the inner level property of the null value it this throwing panic error
if org == nil {
return nil, nil
}
orgName := *org.Login

client := connect(ctx, d)
Expand Down
14 changes: 14 additions & 0 deletions github/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package github
import (
"context"
"os"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -66,8 +67,21 @@ func filterUserLogins(_ context.Context, input *transform.TransformData) (interf
if input.Value == nil {
return user_logins, nil
}

transformValueType := reflect.TypeOf(input.Value)
var userType []*github.User

// Check type of the transform values otherwise it is throwing error while type casting the interface to []*github.User type
if reflect.TypeOf(transformValueType) != reflect.TypeOf(userType){
return nil, nil
}

users := input.Value.([]*github.User)

if users == nil {
return user_logins, nil
}

for _, u := range users {
user_logins = append(user_logins, *u.Login)
}
Expand Down