-
Notifications
You must be signed in to change notification settings - Fork 7
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
[BUG]: GET request for repos/OWNER/REPO/properties/values broken #88
Comments
👋 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 |
I'll note that a workaround to this is fetching the repository directly via repo, err := octokitClient.Repos().ByOwnerId(owner).ByRepoId(repoName).Get(...)
repoProps := repo.GetCustomProperties().GetAdditionalData() |
Hit the same trying to get the current user: error in 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)
} |
What happened?
I'm playing around with this sdk as a means of contributing to integrations/terraform-provider-github#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:The text was updated successfully, but these errors were encountered: