This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tomasfarias
commented
Apr 26, 2024
Comment on lines
+400
to
+402
match response.error_for_status_ref() { | ||
Ok(_) => Ok(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.
Notice we are using a reference to response here when matching as error_for_status
would have taken ownership of the response, and we need to keep ownership if we intend to return it.
tomasfarias
commented
Apr 26, 2024
bretthoerner
approved these changes
Apr 26, 2024
tomasfarias
force-pushed
the
feat/track-response-in-error-details
branch
from
May 2, 2024 10:09
c47f652
to
6743384
Compare
Had to rebase to pull in fix for broken dependency in #32 |
tomasfarias
commented
May 2, 2024
Comment on lines
+44
to
+52
#[derive(Error, Debug)] | ||
pub enum WebhookResponseError { | ||
#[error("failed to parse a response as UTF8")] | ||
ParseUTF8StringError(#[from] std::str::Utf8Error), | ||
#[error("error while iterating over response body chunks")] | ||
StreamIterationError(#[from] reqwest::Error), | ||
#[error("attempted to slice a chunk of length {0} with an out of bounds index of {1}")] | ||
ChunkOutOfBoundsError(usize, usize), | ||
} |
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.
Not handling these at the moment. hook-worker
just defaults to an empty response on error.
bretthoerner
approved these changes
May 2, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When debugging apps, it's useful to have error messages. The problem is that we are only producing to
app_metrics
the message generated byreqwest
(specifically, the message generated by this impl: https://github.com/seanmonstar/reqwest/blob/master/src/error.rs#L185).This error message is useful, but to a limited degree: only status code and url are included in the message. Usually, the server's response can contain more information about what failed. As an example, see how the Django API includes more details on what failed in its default response:
This is valuable information we are currently suppressing in our handling of webhook errors. We should record this error message to be displayed in PostHog to assist with debugging.
Changes:
WebhookJobError
now is initialized directly from aWebhookRequestError
, which is a new enum of errors that contains the response text.WebhookRequestError
appends the response contents, if any.Tests:
Included a unit test to check the error string contains the response body.