Go-github: No way to inspect the body after receiving a 202

Created on 6 Mar 2018  路  5Comments  路  Source: google/go-github

When a 202 is returned, an AcceptedError is returned by client.Do and the resp.Body is closed. The body is never read or decoded into the result parameter, so there is no way to inspect the body. However, I am beta testing an experimental endpoint that returns URLs you need to check the status of your request so I need access to the body.

I am not sure if any existing endpoints return a body in 202s, but some will in the future so it would be nice if we could access the body.

Most helpful comment

@gmlewis This too can be closed as the PR is already merged.

All 5 comments

I am beta testing an experimental endpoint that returns URLs

Can you clarify what you mean? Is it an experimental GitHub REST API v3 endpoint?

If/when GitHub does add an endpoint that returns meaningful data with 202 status code, then we can make changes to support reading the body. I don't think we should do it before that.

We would need to know the schema/encoding of the body to be able to parse it, otherwise the best go-github could do is return it as a byte slice. But that's not very friendly.

Can you clarify what you mean? Is it an experimental GitHub REST API v3 endpoint?

Yes.

If/when GitHub does add an endpoint that returns meaningful data with 202 status code, then we can make changes to support reading the body. I don't think we should do it before that.

I went and looked, some of their existing APIs do too. For example: https://developer.github.com/v3/repos/#transfer-a-repository

We would need to know the schema/encoding of the body to be able to parse it, otherwise the best go-github could do is return it as a byte slice. But that's not very friendly.

This would work exactly the same as all the other endpoints; there is nothing special about 202, yet it is currently special cased and short circuits the Do function before the body is decoded.

I went and looked, some of their existing APIs do too. For example: https://developer.github.com/v3/repos/#transfer-a-repository

Thanks, that鈥檚 helpful. This is the corresponding method in go-github:

https://godoc.org/github.com/google/go-github/github#RepositoriesService.Transfer

I agree, we should support that endpoint returning the repository data when response status code is 202.

@gmlewis This too can be closed as the PR is already merged.

Closing as fixed by #878.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gmlewis picture gmlewis  路  3Comments

smola picture smola  路  3Comments

gmlewis picture gmlewis  路  3Comments

gmlewis picture gmlewis  路  3Comments

adrienzieba picture adrienzieba  路  3Comments