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

Nonsensical errors on connection failure #18

Open
5 of 6 tasks
hchagen opened this issue Mar 15, 2023 · 2 comments
Open
5 of 6 tasks

Nonsensical errors on connection failure #18

hchagen opened this issue Mar 15, 2023 · 2 comments
Labels
bug Something is not working.

Comments

@hchagen
Copy link

hchagen commented Mar 15, 2023

Preflight checklist

Describe the bug

So, I'm not sure if I should report this here, as it's very minor, but if a request to OidcApiService (or probably most the APIs) fails due to a timeout or failure in dns resolving or connection refused or whatever, thus not returning a body, the error reported from the API client is

json: cannot unmarshal object into Go struct field ErrorOAuth2.error of type string

I feel like this could be greatly improved upon by simply checking the type of the error returned, or even reading the response into a buffer and checking its length before decoding - it would be nice to have a less nonsensical error message here, makes it a lot easier to debug when things fail!

Reproducing the bug

Use the SDK (I'm currently on "github.com/ory/client-go" v1.1.21), set it up towards a non-existent host - the specific call that fails for me is most often:

oryClient.OidcApi.DiscoverOidcConfiguration(oryClient.AuthCtx(ctx)).Execute()

and watch the magic unfold!

Relevant log output

2023-03-15 17:57:35.848 [    info] auth-sidecar.auth-sidecar-service-server (leafId=auth-sidecar-service-server, service.env=LOCAL, service.name=auth-sidecar, service.type=go, service.version=web@2914:257e1d77ba1c214e1b66331c9faf6899034ddfc4:origin/feat/grpc-keto) Unable to setup ory client: json: cannot unmarshal object into Go struct field ErrorOAuth2.error of type string, falling back to mock client
2023-03-15 17:57:35.929 [    info] auth-sidecar.auth-sidecar-service-server (leafId=auth-sidecar-service-server, service.env=LOCAL, service.name=auth-sidecar, service.type=go, service.version=web@2914:257e1d77ba1c214e1b66331c9faf6899034ddfc4:origin/feat/grpc-keto) Unable to setup ory client: json: cannot unmarshal object into Go struct field ErrorOAuth2.error of type string, falling back to mock client
2023-03-15 17:57:36.023 [    info] auth-sidecar.auth-sidecar-service-server (leafId=auth-sidecar-service-server, service.env=LOCAL, service.name=auth-sidecar, service.type=go, service.version=web@2914:257e1d77ba1c214e1b66331c9faf6899034ddfc4:origin/feat/grpc-keto) Unable to setup ory client: json: cannot unmarshal object into Go struct field ErrorOAuth2.error of type string, falling back to mock client


### Relevant configuration

```yml
I'm using ory cloud right now, so it's whatever we set up there, I don't think it's particularly relevant :)

Version

v1.1.21

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Ory Network

Additional Context

I think that's most of it, it should be fairly straightforward to fix, I think. Unless, of course, it's caused by the OpenAPI generator, which it very well might be!

@hchagen hchagen added the bug Something is not working. label Mar 15, 2023
@aeneasr
Copy link
Member

aeneasr commented Mar 16, 2023

Thank you for the report! I do believe that the problem here is in fact the OpenAPI generated code :(

@ThisDevDane
Copy link

ThisDevDane commented Mar 27, 2023

I'm hitting this problem on the oryClient.OAuth2Api.Introspect2Token(...) call, sort of making ory completely useless to me :/ Am on the latest tag 'v1.1.23'

edit: okay not completely useless as I realized I could just red from the response directly, but I can say that this occurs even if the message does have a body

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

3 participants