-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add RequestError and GraphQLError types to indicate server failure and graphql failure. #95
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
30f36bb
to
f8a6768
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgorven can correct me if I'm wrong, but I'm not sure if this totally solves what they're looking for. The most important piece is being able to tell "is this my fault or lightspark's fault and should I retry". @mgorven is it true that anything with an extension is likely to be a non-retryable user error?
I think the RequestError will be the things for them to retry. GraphQLError is the error returned from graphql. All other errors are the errors with their code. I don't think they should retry on GraphQLError here but it did indicate either side have a bug in code that needs to be fixed. |
It's mostly but not completely true. There are a few cases where we have an extension but it's not necessarily the user's fault (exception classes here which inherit directly from ExternalException, currently NoRoutes and CardPaymentError).
In principal you're right, but in practice I think customers might want to. e.g. if sparkcore fails to communicate with sparknode because it's restarting that would surface as a graphql error (with no error_name). |
So basically: @mgorven do you think they can retry on NoRoutes and CardPaymentError? If so I think we need to add a boolean field in the GraphQLError to indicate which one can be retried. |
CardPaymentError is only used for billing, so not relevant for the SDK. I don't think that retrying NoRoute is going to help (if routefinder can't find a route it's not going to have one a few seconds later). |
I can probably break the GraphQLError into two separate ones so one can retry while the other cannot. |
f8a6768
to
111dc54
Compare
|
Can we document (in code) the error structs to this effect so that callers can see what to do with each type? |
111dc54
to
8184abc
Compare
requester/requester.go
Outdated
"strings" | ||
"time" | ||
|
||
lightspark "github.com/lightsparkdev/go-sdk" | ||
) | ||
|
||
// RequestError indicates that a request to the Lightspark API failed. | ||
// It could be due to a service outage or a network error. | ||
// The request should be retried if RequestError is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgorven Do we ever return a 401 or 403 or are all http error codes deferred to graphql errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. This error is early returned before parsing graphql response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but I'm suggesting that really only 5XX errors should be retries, likely not all 4XX errors if our backend is returning those (which it seems to do)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We return 401 if an API token is provided but is invalid. It is also possible (but rare) for requests to fail with HTTP 500.
…d graphql failure.
25692f7
to
e2c76a0
Compare
Fixes LIG-5257