Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Commit

Permalink
Fix unable to resolve node id for branch_protection (integrations#610)
Browse files Browse the repository at this point in the history
* Don't check node id for length

* Check if node id is valid base 64

Co-authored-by: Willem Gillis <willem.gillis@imec.be>
  • Loading branch information
Polygens and Polygens authored Dec 8, 2020
1 parent f6add3e commit 65e8c3f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions github/util_v4_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package github

import (
"context"
"encoding/base64"

"github.com/shurcooL/githubv4"
)
Expand Down Expand Up @@ -38,8 +39,9 @@ func getRepositoryID(name string, meta interface{}) (githubv4.ID, error) {
}

func repositoryNodeIDExists(name string, meta interface{}) (bool, error) {
// Quick check for node ID length
if len(name) != 32 {
// Check if the name is a base 64 encoded node ID
_, err := base64.StdEncoding.DecodeString(name)
if err != nil {
return false, nil
}

Expand All @@ -54,7 +56,7 @@ func repositoryNodeIDExists(name string, meta interface{}) (bool, error) {
}
ctx := context.Background()
client := meta.(*Owner).v4client
err := client.Query(ctx, &query, variables)
err = client.Query(ctx, &query, variables)
if err != nil {
return false, err
}
Expand Down

0 comments on commit 65e8c3f

Please sign in to comment.