Skip to content

[BUG]: NullReferenceException thrown using IConnection.GetRaw() for JSON content in Octokit 8.0.1 #2789

@martincostello

Description

@martincostello

What happened?

Calling IConnection.GetRaw() for an endpoint that responds with non-binary content (e.g. application/json) results in a NullReferenceException being thrown when updating to Octokit 8.0.1.

This appears to be due to the changes in #2782 to handle large binary responses.

In the case where the response is not a Stream but instead is just a string, response.Body as Stream returns null, and then causes an exception here:

await stream.CopyToAsync(ms);

Fix incoming shortly, but a workaround is to use IConnection.GetRawStream() and refactor calling code to deal with Stream instead of byte[].

Versions

8.0.1

Relevant log output

System.NullReferenceException: Object reference not set to an instance of an object.
    at Octokit.Connection.StreamToByteArray(Stream stream) in /_/Octokit/Http/Connection.cs:line 724
    at Octokit.Connection.GetRaw(IRequest request) in /_/Octokit/Http/Connection.cs:line 704
    at MartinCostello.Costellobot.Pages.DeliveryModel.OnGet(Int64 id) in /_/src/Costellobot/Pages/Webhooks/Delivery.cshtml.cs:line 64

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions