Skip to content

Commit

Permalink
fix: return body to hog if we get a bad response code (#24287)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverb123 authored Aug 13, 2024
1 parent 90071b9 commit e882507
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions rust/hook-worker/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,10 @@ async fn process_webhook_job<W: WebhookJob>(

match request_error {
WebhookRequestError::RetryableRequestError {
error, retry_after, ..
error,
retry_after,
response, // Grab the response so we can send it back to hog for debug
..
} => {
let retry_interval =
retry_policy.retry_interval(webhook_job.attempt() as u32, retry_after);
Expand Down Expand Up @@ -623,7 +626,7 @@ async fn process_webhook_job<W: WebhookJob>(
Some(status) => Ok(WebhookResult::BadResponse(WebhookResponse {
duration: now.elapsed(),
status_code: status,
body: None,
body: response,
})),
None => Ok(WebhookResult::Error(error.to_string())),
}
Expand All @@ -634,7 +637,9 @@ async fn process_webhook_job<W: WebhookJob>(
}
}
}
WebhookRequestError::NonRetryableRetryableRequestError { error, .. } => {
WebhookRequestError::NonRetryableRetryableRequestError {
error, response, ..
} => {
webhook_job
.fail(webhook_job_error)
.await
Expand All @@ -649,7 +654,7 @@ async fn process_webhook_job<W: WebhookJob>(
Some(status) => Ok(WebhookResult::BadResponse(WebhookResponse {
duration: now.elapsed(),
status_code: status,
body: None,
body: response,
})),
None => Ok(WebhookResult::Error(error.to_string())),
}
Expand Down Expand Up @@ -1126,7 +1131,7 @@ mod tests {
let received_response = async_function_response.get("response").unwrap();
assert_eq!(
json!({
"body": None::<String>, // TODO: We should still return the response.
"body": Some("{\"message\": \"bad response\"}"),
"status": 500
}),
*received_response
Expand Down

0 comments on commit e882507

Please sign in to comment.