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

Errorsource's RoundTripper returns custom error alongside response #846

Open
cletter7 opened this issue Dec 19, 2023 · 3 comments
Open

Errorsource's RoundTripper returns custom error alongside response #846

cletter7 opened this issue Dec 19, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@cletter7
Copy link
Contributor

It seems not ideal that the errorsource's round tripper returns custom generated error together with the response for certain status codes here: https://github.com/grafana/grafana-plugin-sdk-go/blob/main/experimental/errorsource/error_source_middleware.go#L21-L26

Because the Go http client ignores the response in case round tripper returns the error: https://github.com/golang/go/blob/6fe0d3758b35afcc342832e376d8d985a5a29070/src/net/http/client.go#L262-L264.
The response body might contain useful information for the user.

cc @scottlepp

@cletter7 cletter7 added the bug Something isn't working label Dec 19, 2023
@academo
Copy link
Member

academo commented Feb 28, 2024

@cletter7 can you specify what is your expected return value?

@academo academo added enhancement New feature or request and removed bug Something isn't working labels Feb 28, 2024
@cletter7
Copy link
Contributor Author

I am not sure if just changing the return value would help here. Ideally when I use errorsource middleware or htpp client I would like error source to be handled automatically, but at the same time I want to be able to access the response if there is response. The problem with the current approach is that response is lost when status code is >= 400. Maybe we need to extend/override http client later in the chain or use some other approach to achieve the desired result.

@cletter7
Copy link
Contributor Author

@scottlepp maybe you have something to add here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants