Some retrieve functions in client package swallow the errors
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?
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
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.
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.