-
Notifications
You must be signed in to change notification settings - Fork 48
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
Rest client support for endpoint not returning a JSON #161
Comments
This shows that returning an empty body, with a non-error status code will break DoWithContext because it will try to unmarshal an invalid JSON string.
I was curious about what the stated about RFC 7231 > 6.3.6 > "205 Reset Content", so thought I'd look it up:
I think we all agree #163 is a clear ✅ as regardless of how the server is indicating to the client, there should be no content and we can just skip the rest. My concern in #162 — skip unmarshaling the response if empty — is whether it hides a potential err from the caller. |
I'm glad to hear, let's see on the PR how we can make the tests better. I'll open it up for review.
I agree with this assessment, there needs to be a better error handling. Currently, the only error we get is I was considering requesting to also get additional HTTP information out of those methods, so that specific error codes could be dealt with by the client. |
Can you think of an example of a scenario in which a developer using |
Problem statement
While working on
gh-not
I started experimenting with Actors interacting with the GitHub API.A very simple one would be to mark a notification as
read
, as per https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#mark-a-thread-as-read.Here's a simplified version of the code I wanted to use:
And I always get:
panic: unexpected end of JSON input
Possible fix 1
The documentation specifies status codes, but no response content; expecting one is thus useless in this context.
I wonder if
go-gh/pkg/api/rest_client.go
Lines 103 to 111 in dbd982e
This would prevent breaking on invalid JSON when none is expected.
POC implemented in #162
Possible fix 2
The
205
status code spec specifies:So maybe a better fix would be:
Implementation PR: #163
Current workaround
Additional questions
go-gh
's REST client for Patch requests if the endpoint doesn't return a valid JSON?The text was updated successfully, but these errors were encountered: