You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running queries with invalid API credentials or bad request payloads, I would expect there to be some HTTP error returned (400, 401, 403, 404, etc) and sometimes a response body describing what went wrong. I've tried creating, listing and fetching individual entities, and it seems like in each case the HTTP error code and the error body is swallowed up internally in go-freshservice and is never available to me.
Actual Behavior
List queries return an empty slice [], while individual queries return nil. No errors are returned.
Steps to Reproduce
ctx:=context.Background()
// I should get a 404 error hereapi, err:=fs.New(ctx, "fakedomain.freshservice.com", "badApikey", nil)
iferr!=nil {
log.Fatal(err)
}
agents, _, agentsError:=api.Agents().List(ctx, nil)
// agents is []// agentsError is nil
Thoughts
This lack of access to HTTP error codes or error bodies almost seems to be by design when I take a look at the source code.
Even if the ErrorResponse interface is used conditionally in makeRequest to decode the response body, we always return &res.Details or &res.List in the query functions like Agents().List. Thus, the fields from ErrorResponse, namely Description and Errors are never used for anything and are simply discarded. The HTTP response status code is also never returned from makeRequest so that is definitely not available to me.
The existence of the ErrorResponse interface clearly indicates that HTTP errors, or at least freshservice API errors, are supposed to be handled somehow. But I'm not seeing how that can be done the way the queries are written today.
Is there something here I have misunderstood or is the codebase simply at such an early stage that error handling was never prioritised and every query is assumed to run successfully?
The text was updated successfully, but these errors were encountered:
Version
v0.0.2
Endpoint
Any endpoint. I've tried Agent and Announcement
Expected Behavior
When running queries with invalid API credentials or bad request payloads, I would expect there to be some HTTP error returned (400, 401, 403, 404, etc) and sometimes a response body describing what went wrong. I've tried creating, listing and fetching individual entities, and it seems like in each case the HTTP error code and the error body is swallowed up internally in go-freshservice and is never available to me.
Actual Behavior
List queries return an empty slice
[]
, while individual queries returnnil
. No errors are returned.Steps to Reproduce
Thoughts
This lack of access to HTTP error codes or error bodies almost seems to be by design when I take a look at the source code.
Even if the
ErrorResponse
interface is used conditionally inmakeRequest
to decode the response body, we always return&res.Details
or&res.List
in the query functions likeAgents().List
. Thus, the fields fromErrorResponse
, namelyDescription
andErrors
are never used for anything and are simply discarded. The HTTP response status code is also never returned frommakeRequest
so that is definitely not available to me.The existence of the
ErrorResponse
interface clearly indicates that HTTP errors, or at least freshservice API errors, are supposed to be handled somehow. But I'm not seeing how that can be done the way the queries are written today.Is there something here I have misunderstood or is the codebase simply at such an early stage that error handling was never prioritised and every query is assumed to run successfully?
The text was updated successfully, but these errors were encountered: