Skip to content

Commit 2f0fddb

Browse files
Add some debug logging for request building
It's suspected that there's a failure of some kind arising when we attempt to set labels on GitHub issues, but it isn't yet clear what that failure is. Our logs so far just say "builder error: unsupported value" which is pretty unhelpful, though it does seem like it is coming from reqwest (the "builder error" string at least).
1 parent 2c720ff commit 2f0fddb

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/github.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ pub struct User {
1818
}
1919

2020
impl GithubClient {
21-
async fn _send_req(&self, req: RequestBuilder) -> Result<(Response, String), reqwest::Error> {
21+
async fn _send_req(&self, req: RequestBuilder) -> anyhow::Result<(Response, String)> {
2222
const MAX_ATTEMPTS: usize = 2;
2323
log::debug!("_send_req with {:?}", req);
24-
let req = req.build()?;
2524
let req_dbg = format!("{:?}", req);
25+
let req = req
26+
.build()
27+
.with_context(|| format!("building reqwest {}", req_dbg))?;
2628

2729
let mut resp = self.client.execute(req.try_clone().unwrap()).await?;
2830
if let Some(sleep) = Self::needs_retry(&resp).await {
@@ -272,7 +274,7 @@ where
272274
#[derive(Debug)]
273275
pub enum AssignmentError {
274276
InvalidAssignee,
275-
Http(reqwest::Error),
277+
Http(anyhow::Error),
276278
}
277279

278280
#[derive(Debug)]
@@ -516,9 +518,11 @@ impl Issue {
516518
}
517519
}
518520
Err(e) => {
519-
if e.status() == Some(reqwest::StatusCode::NOT_FOUND) {
520-
log::debug!("set_assignee: assignee is invalid, returning");
521-
return Err(AssignmentError::InvalidAssignee);
521+
if let Some(e) = e.downcast_ref::<reqwest::Error>() {
522+
if e.status() == Some(reqwest::StatusCode::NOT_FOUND) {
523+
log::debug!("set_assignee: assignee is invalid, returning");
524+
return Err(AssignmentError::InvalidAssignee);
525+
}
522526
}
523527
log::debug!("set_assignee: get {} failed, {:?}", check_url, e);
524528
return Err(AssignmentError::Http(e));

src/handlers/major_change.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ impl Handler for MajorChangeHandler {
6363
// All other issue events are ignored
6464
return Ok(None);
6565
}
66-
Event::IssueComment(e) => {}
66+
Event::IssueComment(_) => {}
6767
}
6868

6969
let mut input = Input::new(&body, &ctx.username);
7070
let command = input.parse_command();
71-
71+
7272
if let Some(previous) = event.comment_from() {
7373
let mut prev_input = Input::new(&previous, &ctx.username);
7474
let prev_command = prev_input.parse_command();
7575
if command == prev_command {
7676
return Ok(None);
7777
}
7878
}
79-
79+
8080
match command {
8181
Command::Second(Ok(SecondCommand)) => Ok(Some(Invocation::Second)),
8282
_ => Ok(None),
@@ -215,7 +215,7 @@ async fn handle_input(
215215
let zulip_req = zulip_req.send(&ctx.github.raw());
216216

217217
let (gh_res, zulip_res) = futures::join!(github_req, zulip_req);
218-
gh_res?;
219-
zulip_res?;
218+
zulip_res.context("zulip post failed")?;
219+
gh_res.context("label setting failed")?;
220220
Ok(())
221221
}

0 commit comments

Comments
 (0)