-
Notifications
You must be signed in to change notification settings - Fork 1
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
Error reporting improvements #22
Conversation
I notice the Java SDK just returns the HTTP errors directly (e.g. 404 for not found). I suspect that was a deliberate choice by @bradlo and that we should probably do the same here. |
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.
Looks good to me. One question, but mostly just curious. And thank you for the updates to the changelog.
RelationalAI/Errors/ApiException.cs
Outdated
{ | ||
StatusCode = statusCode; | ||
Response = response; | ||
Headers = headers; |
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.
am curious why the api exception carries the HTTP headers? in the other SDKs we generally try to abstract away transport details at the API layer.
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.
@bradlo we really need that for the request id, as that's always important for tracing. We could extract the X-Request-ID header value and pass it directly if we know the exact header name.
Co-authored-by: Stanislav Bedunkevich <[email protected]>
if (status != 404 && status < 500) | ||
{ | ||
return; | ||
} |
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.
what happens if resource is forbidden (403) ? Do we swallow client errors other than 404 ?
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.
@NRHelmi yeah, we mostly wanted to leave the behaviour as it was before. I think it's better for the SDK team to agree on the http status code handling to be consistent across all of the SDKs.
The reason for 5xx is simple, as we run into them (occasionally we do), we want to be able to see the request id in logs.
Your point is very valid though, but we'd like to leave it out of the scope of this PR is that's fine with you?
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.
Thank you for the clarification, can we create an issue as part of the project ?
cc @bradlo
RelationalAI/Services/Rest.cs
Outdated
@@ -293,14 +314,14 @@ private async Task<AccessToken> RequestAccessTokenAsync(string host, ClientCrede | |||
var resp = await RequestHelperAsync("POST", creds.ClientCredentialsUrl, data); | |||
if (!(resp is string stringResponse)) | |||
{ | |||
throw new SystemException("Unexpected response type"); | |||
throw new InvalidResponseException("Unexpected response type, expected a string", resp); |
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.
maybe also include the current response type in the exception message
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.
@NRHelmi addressed in the latest commit. Thank you.
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.
thank you 🙏
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.
thank you :)
SystemException
s with more meaningful errors and improves messages.Partly addresses #12, but there are still places to improve.
TODO: