-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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]: NullReferenceException thrown using IConnection.GetRaw() for JSON content in Octokit 8.0.1 #2789
Comments
Found through failing tests in these two Dependabot updates: |
Use `IConnection.GetRawStream()` instead of `IConnection.GetRaw()` to improve the code and also work around octokit/octokit.net#2789.
Also affects |
* Bump Octokit from 8.0.0 to 8.0.1 Bumps [Octokit](https://github.com/octokit/octokit.net) from 8.0.0 to 8.0.1. - [Release notes](https://github.com/octokit/octokit.net/releases) - [Changelog](https://github.com/octokit/octokit.net/blob/main/docs/releases.md) - [Commits](octokit/octokit.net@v8.0.0...v8.0.1) --- updated-dependencies: - dependency-name: Octokit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Use IConnection.GetRawStream() Use `IConnection.GetRawStream()` instead of `IConnection.GetRaw()` to improve the code and also work around octokit/octokit.net#2789. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: martincostello <martin@martincostello.com>
Hey @martincostello great catch. 🤦 This one is on me, I reviewed it and let it through and completely missed the implementations that you mentioned above. I'll have a look at |
No problem! I did push up a fix in #2791 but I fat-fingered the number into the other fix for GitVersion and it got closed when you merged it 🤦🏻♂️ |
* Fix handling for Streams Fix `NullReferenceException` if raw content was handled as a string rather than a stream by `HttpClientAdapter.BuildResponse()`. Resolves #2789. * Add Connection.GetRaw tests Add tests for `Connection.GetRaw()` and for #2789. --------- Co-authored-by: Keegan Campbell <me@kfcampbell.com>
What happened?
Calling
IConnection.GetRaw()
for an endpoint that responds with non-binary content (e.g.application/json
) results in aNullReferenceException
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 astring
,response.Body as Stream
returnsnull
, and then causes an exception here:octokit.net/Octokit/Http/Connection.cs
Line 724 in 0238092
Fix incoming shortly, but a workaround is to use
IConnection.GetRawStream()
and refactor calling code to deal withStream
instead ofbyte[]
.Versions
8.0.1
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: