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

[BUG]: Users[].GetAsync() does not return correct data #87

Open
1 task done
martincostello opened this issue Jun 17, 2024 · 5 comments
Open
1 task done

[BUG]: Users[].GetAsync() does not return correct data #87

martincostello opened this issue Jun 17, 2024 · 5 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@martincostello
Copy link
Contributor

What happened?

Using the GitHubClient.Users[].GetAsync() returns a value with a null value for the PublicUser and PrivateUser properties.

The generated code to call /users/{login} appears to not be expecting the correct payload:

public static WithUsernameGetResponse CreateFromDiscriminatorValue(IParseNode parseNode)
{
    if (parseNode == null)
    {
        throw new ArgumentNullException("parseNode");
    }

    string value = parseNode.GetChildNode("")?.GetStringValue();
    WithUsernameGetResponse withUsernameGetResponse = new WithUsernameGetResponse();
    if ("private-user".Equals(value, StringComparison.OrdinalIgnoreCase))
    {
        withUsernameGetResponse.PrivateUser = new PrivateUser();
    }
    else if ("public-user".Equals(value, StringComparison.OrdinalIgnoreCase))
    {
        withUsernameGetResponse.PublicUser = new PublicUser();
    }

    return withUsernameGetResponse;
}

I would expect it to just return the user as-is:

{
  "login": "martincostello",
  "id": 1439341,
  "node_id": "MDQ6VXNlcjE0MzkzNDE=",
  "avatar_url": "https://avatars.githubusercontent.com/u/1439341?v=4",
  "gravatar_id": "",
  "url": "https://api.github.com/users/martincostello",
  "html_url": "https://github.com/martincostello",
  "followers_url": "https://api.github.com/users/martincostello/followers",
  "following_url": "https://api.github.com/users/martincostello/following{/other_user}",
  "gists_url": "https://api.github.com/users/martincostello/gists{/gist_id}",
  "starred_url": "https://api.github.com/users/martincostello/starred{/owner}{/repo}",
  "subscriptions_url": "https://api.github.com/users/martincostello/subscriptions",
  "organizations_url": "https://api.github.com/users/martincostello/orgs",
  "repos_url": "https://api.github.com/users/martincostello/repos",
  "events_url": "https://api.github.com/users/martincostello/events{/privacy}",
  "received_events_url": "https://api.github.com/users/martincostello/received_events",
  "type": "User",
  "site_admin": false,
  "name": "Martin Costello",
  "company": "@justeattakeaway",
  "blog": "https://martincostello.com",
  "location": "London, UK",
  "email": null,
  "hireable": null,
  "bio": ".NET developer, tester and Microsoft MVP based in London working for Just Eat Takeaway.com",
  "twitter_username": "martin_costello",
  "public_repos": 163,
  "public_gists": 13,
  "followers": 504,
  "following": 20,
  "created_at": "2012-02-15T09:43:20Z",
  "updated_at": "2024-06-08T18:05:14Z"
}

Versions

0.0.16

Code of Conduct

  • I agree to follow this project's Code of Conduct
@martincostello martincostello added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jun 17, 2024
Copy link

👋 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! 🚀

@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Jun 17, 2024
@kfcampbell
Copy link
Member

Ooh, interesting find. I've confirmed this, and when you remove the if ("private-user".Equals(value, StringComparison.OrdinalIgnoreCase)) logic, the response gets populated exactly as you'd expect.

I'm going to file an issue with Kiota for this.

@kfcampbell
Copy link
Member

Reported upstream at microsoft/kiota#4844!

@martincostello
Copy link
Contributor Author

The upstream issue seems to have been closed due to a lack of activity. Looks like they say the OpenAPI schema is wrong as it doesn't have a discriminator?

@kfcampbell
Copy link
Member

Yep, they're correct. We need to update the schema internally; our team just hasn't had the time yet. We'll keep this open and return to it when we can!

@nickfloyd nickfloyd assigned nickfloyd and unassigned nickfloyd Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

3 participants