octokit / go-sdk

A generated Go SDK from GitHub's OpenAPI specification. Built on Kiota.
MIT License
66 stars 6 forks source link

[BUG]: Getting issue by issue number panics if there is a label present on issue #119

Open kfcampbell opened 1 day ago

kfcampbell commented 1 day ago

What happened?

I'm using the following code snippet:

    client, err := pkg.NewApiClient(
        pkg.WithUserAgent("my-user-agent"),
        pkg.WithRequestTimeout(5*time.Second),
        pkg.WithBaseUrl("https://api.github.com"),
        pkg.WithTokenAuthentication(os.Getenv("GITHUB_TOKEN")),
    )

    if err != nil {
        log.Fatalf("error creating client: %v", err)
    }

    queryParams := &abs.DefaultQueryParameters{}
    requestConfig := &abs.RequestConfiguration[abs.DefaultQueryParameters]{
        QueryParameters: queryParams,
    }

    issue, err := client.Repos().ByOwnerId("hilli").ByRepoId("issue-test").Issues().ByIssue_number(1).Get(context.Background(), requestConfig)
    if err != nil {
        log.Fatalf("error getting issue: %v", err)
    }
    fmt.Printf("issue: %+v", issue)

This code panics, since https://github.com/hilli/issue-test/issues/1 has a label on it. There's some kind of issue going on in which labels aren't being deserialized correctly. See a debugging screenshot in which we attempt to force unwrap a nil value for the label:

Image

The final panic is:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9e6418]

By contrast, the same request to https://github.com/kfcampbell/a-repo/issues/1 succeeds, as it doesn't have any issues in place:

issue: &{active_lock_reason:<nil> additionalData:map[] assignee:<nil> assignees:[] author_association:0xc0000152d8 body:0xc000234d40 body_html:<nil> body_text:<nil> closed_at:<nil> closed_by:<nil> comments:0xc0000152e0 comments_url:0xc000234340 created_at:0xc00025fa40 draft:<nil> events_url:0xc000234390 html_url:0xc0002343e0 id:0xc000015300 labels:[] labels_url:0xc0002342f0 locked:0xc000014cee milestone:<nil> node_id:0xc000234460 number:0xc0000152d4 performed_via_github_app:<nil> pull_request:<nil> reactions:0xc00026d260 repository:<nil> repository_url:0xc0002342a0 state:0xc000234ac0 state_reason:<nil> timeline_url:0xc000234fe0 title:0xc0002344e0 updated_at:0xc00025fa28 url:0xc000234250 user:0xc00013e580}

Note that label IDs have already been updated to int64 from what I can tell.

Versions

Most recent go-sdk from source (v0.0.29).

Code of Conduct

github-actions[bot] commented 1 day 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! 🚀