Open felixlut opened 4 months ago
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs
. You & others like you are the reason all of this works! So thank you & happy coding! 🚀
I'll note that a workaround to this is fetching the repository directly via octokitClient.Repos().ByOwnerId(owner).ByRepoId(repoName).Get()
, which parses the custom properties of the repo correctly. Looks something like:
repo, err := octokitClient.Repos().ByOwnerId(owner).ByRepoId(repoName).Get(...)
repoProps := repo.GetCustomProperties().GetAdditionalData()
Hit the same trying to get the current user:
error in user_request_builder
package dev
import (
"context"
"fmt"
"os"
octokit "github.com/octokit/go-sdk/pkg"
)
func main() {
gh, err := octokit.NewApiClient(
octokit.WithUserAgent("my-thing"),
octokit.WithTokenAuthentication(os.Getenv("GITHUB_TOKEN")),
)
if err != nil {
fmt.Println("error: ", err)
}
ctx := context.Background()
user, err := gh.User().Get(ctx, nil)
if err != nil {
fmt.Println("error: ", err) // panic: index is empty
}
fmt.Println("user: ", user)
}
Bumping into the same issue with client.Repos().ByOwnerId(owner).ByRepoId(repo).Rulesets().ByRuleset_id(rulesetId).Get()
, which is mapped to /repos/{owner}/{repo}/rulesets/{ruleset_id}
. The parseNode.GetChildNode("")
causes an error of index is empty
at this line as well.
// err == index is empty
response, err := client.Repos().ByOwnerId(owner).ByRepoId(repo).Rulesets().ByRuleset_id(rulesetId).Get(context.background(), nil)
What happened?
I'm playing around with this sdk as a means of contributing to https://github.com/integrations/terraform-provider-github/issues/1956, and as such my focus is on the endpoints related to repository custom properties.
The issue I'm facing occurs when calling
octokitClient.Repos().ByOwnerId(owner).ByRepoId(repoName).Properties().Values().Get()
, which is mapped to therepos/OWNER/REPO/properties/values
GET
endpoint. I'll list the code I'm using further down in the message.When running the code on a repository where no custom properties are set, it works as intended by returning an empty list. But when using it on a repo where any custom property is set, the error below is the result. I've played around with properties of all available types (
true_false
,single_select
,multi_select
, andtext
), and all of them have this error. Error:panic: index is empty
.For example, if I add a custom property called
text
with a value oftest
, I get the following response while using thegh
cli (gh api repos/YesWeKanske/test-custom-properties/properties/values
):But I get the
index is empty
error with the code I've posted below.I've ran a debugger and tracked this error down to this line in the
microsoft/kiota-serialization-json-go
library, which is being called from this line inpkg/github/models/custom_property_value.go
. From what I can gather this part of the code is for converting the value (in this case the string"test"
) of a custom property to the structs the Kiota framework can parse (or something). Point is that it deals with thevalue
of a custom property.I'd be lying if I said I understand exactly what Kiota is doing under the hood, but the
parseNode.GetChildNode("")
looks weird to me. Calling that with an empty string will always render in an error, and there are quite a few examples throughout the codebase of this occurring. I've only tested it with the repository custom properties, but I'd assume the same errors would occur for any of the other resources as well.My code:
Versions
I've used the latest version of the provider at the time of writing this bug report (
go get github.com/octokit/go-sdk@a74a3a2a13654bd84794fd91a6a0fbc96f883722
, wherea74a3a2a13654bd84794fd91a6a0fbc96f883722
is a commit to this repo). Mygo.mod
file looks like so:Code of Conduct