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

[fix] Fix handling for Streams in IConnection for raw content #2791

Merged
merged 3 commits into from
Nov 7, 2023

Conversation

martincostello
Copy link
Contributor

Fix NullReferenceException if raw content was handled as a string rather than a stream by HttpClientAdapter.BuildResponse().

I haven't added a test for this, but have validated that the apps that surfaced this issue are working when using a local build of Octokit including this change. If you can direct me to exactly where you'd like a test for this, I'll add one.

Resolves #2789


Before the change?

  • A NullReferenceException would be thrown.

After the change?

  • The call succeeds.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

  • Yes
  • No

@martincostello martincostello mentioned this pull request Oct 2, 2023
4 tasks
@nickfloyd nickfloyd added the Type: Bug Something isn't working as documented label Oct 2, 2023
@nickfloyd nickfloyd closed this in 12e29ab Oct 3, 2023
@martincostello martincostello deleted the fix-stream-handling branch October 3, 2023 17:11
@martincostello martincostello restored the fix-stream-handling branch October 3, 2023 17:12
@martincostello
Copy link
Contributor Author

Looks like this got closed by accident because I put the wrong # in the commit message for the other PR, and I can't re-open it.

@martincostello
Copy link
Contributor Author

@nickfloyd Anything more you need from me to progress this fix?

@kfcampbell
Copy link
Member

I do think it'd be possible to write a test for this case in Octokit.Tests/Http/ConnectionTests.cs, since the modified GetRaw is called by two public functions. Why don't we try doing so?

Fix `NullReferenceException` if raw content was handled as a string rather than a stream by `HttpClientAdapter.BuildResponse()`.
Resolves #2789.
Add tests for `Connection.GetRaw()` and for #2789.
Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@kfcampbell kfcampbell merged commit 4f826bc into octokit:main Nov 7, 2023
5 checks passed
@martincostello martincostello deleted the fix-stream-handling branch November 7, 2023 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

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