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]: Deserializing https://api.github.com/repos/{owner}/{repository} to Octokit.Webhooks.Models.Repository will throw #526

Closed
1 task done
OoLunar opened this issue Jul 3, 2024 · 3 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

@OoLunar
Copy link

OoLunar commented Jul 3, 2024

What happened?

When attempting to deserialize a successful rest request response from https://api.github.com/repos/{owner}/{repository} to Octokit.Webhooks.Models.Repository, STJ will throw the following exception:

System.Text.Json.JsonException: The JSON value could not be converted to System.String. Path: $.organization | LineNumber: 0 | BytePositionInLine: 5592.
 ---> System.InvalidOperationException: Cannot get the value of a token type 'StartObject' as a string.
   at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedString(JsonTokenType tokenType)
   at System.Text.Json.Utf8JsonReader.GetString()
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
   at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, JsonSerializerOptions options, CancellationToken cancellationToken)

I suspect this is because Octokit.Webhooks.Models.Repository should be of type Octokit.Webhooks.Models.Organization instead of a string. When reproducing, ensure the repository you're calling the route on belongs to an organization, not a user.

Versions

  • Dotnet SDK: 8.0.302
  • Octokit.Webhooks NuGet package: 2.2.2

Relevant log output

No response

Code of Conduct

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

github-actions bot commented Jul 3, 2024

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

@github-project-automation github-project-automation bot moved this to 🆕 Triage in 🧰 Octokit Active Jul 3, 2024
@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 Jul 3, 2024
@kfcampbell kfcampbell moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Jul 3, 2024
@JamieMagee
Copy link
Contributor

When attempting to deserialize a successful rest request response from https://api.github.com/repos/{owner}/{repository} to Octokit.Webhooks.Models.Repository

This library isn't designed to deserialize REST API Responses. I think you might be looking for https://github.com/octokit/octokit.net

@JamieMagee
Copy link
Contributor

@OoLunar I'm closing this for now, as I don't believe this library is the correct one for what you're doing. Please leave a comment if I've misunderstood and I can re-open the issue.

@github-project-automation github-project-automation bot moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Active Jul 8, 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
Archived in project
Development

No branches or pull requests

3 participants