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

Some retrieve functions in client package swallow the errors #69

Open
jizh6311 opened this issue Oct 7, 2022 · 3 comments
Open

Some retrieve functions in client package swallow the errors #69

jizh6311 opened this issue Oct 7, 2022 · 3 comments

Comments

@jizh6311
Copy link

jizh6311 commented Oct 7, 2022

I realize some client functions add nil error reference to the next call. For example: https://github.com/FusionAuth/go-client/blob/master/pkg/fusionauth/Client.go#L3420. Is that intentional? (But some other functions declare an error and pass it to the next call)

I had some bad experience with troubleshooting when I had the wrong FusionAuth API. Perhaps getting an explicit 401 error is more helpful?

@mooreds
Copy link
Contributor

mooreds commented Oct 11, 2022

Hi @jizh6311 ,

Can you share some of the code that you wrote where this behavior was problematic?

I think I know what you ran into, but would love to see it from you just so I'm not making assumptions.

Here's the code that generates the go client library: https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/go.client.ftl#L22

@jizh6311
Copy link
Author

Hi @jizh6311 ,

Can you share some of the code that you wrote where this behavior was problematic?

I think I know what you ran into, but would love to see it from you just so I'm not making assumptions.

Here's the code that generates the go client library: https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/go.client.ftl#L22

@mooreds Thanks for your reply! What I ran into was straightforward: when the apiKey was invalid, this code section was unable to get the unauthorized error. Instead, the error was nil.

  ...
  fusionAuthClient := NewClient(httpClient, baseURL, apiKey)
  groups, err := fusionAuthClient.RetrieveGroups()
  if err != nil {
    // log the errors
  } 

More specifically, I notice the error is void in the json for retrieveGroups: https://github.com/FusionAuth/fusionauth-client-builder/blob/3092673bc052942d430ba5c946824cac4352ed33/src/main/api/retrieveGroups.json, but it is Errors in some other json files: https://github.com/FusionAuth/fusionauth-client-builder/blob/3092673bc052942d430ba5c946824cac4352ed33/src/main/api/addUserToFamily.json#L9.

@mooreds
Copy link
Contributor

mooreds commented Oct 11, 2022

Yes, I was seeing that too. I think it might be because we always expect a response back from the groups API (unless, of course, the server is down or the API key is invalid). Will think about this a bit. Appreciate the response.

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

No branches or pull requests

2 participants