Skip to content

Commit

Permalink
Merge pull request #1821 from apiraino/guard-against-overflowing-comm…
Browse files Browse the repository at this point in the history
…ent-ids

Guard against overflowing GitHub ID comments
  • Loading branch information
ehuss authored Jul 2, 2024
2 parents ce4a18e + 052db39 commit 0ddb063
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
28 changes: 21 additions & 7 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl Issue {
self.state == IssueState::Open
}

pub async fn get_comment(&self, client: &GithubClient, id: u64) -> anyhow::Result<Comment> {
pub async fn get_comment(&self, client: &GithubClient, id: i32) -> anyhow::Result<Comment> {
let comment_url = format!("{}/issues/comments/{}", self.repository().url(client), id);
let comment = client.json(client.get(&comment_url)).await?;
Ok(comment)
Expand Down Expand Up @@ -1825,20 +1825,34 @@ impl<'q> IssuesQuery for Query<'q> {
issue.html_url, fcp.fcp.fk_bot_tracking_comment
);
let bot_tracking_comment_content = quote_reply(&fcp.status_comment.body);

let fk_initiating_comment = fcp.fcp.fk_initiating_comment;
let init_comment = issue
.get_comment(&client, fk_initiating_comment.try_into()?)
.await?;
let (initiating_comment_html_url, initiating_comment_content) =
if u32::try_from(fk_initiating_comment).is_err() {
// We blew out the GH comment incremental counter (a i32 on their end)
// See: https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/rfcbot.20asleep
log::debug!("Ignoring overflowed comment id from GitHub");
("".to_string(), "".to_string())
} else {
let comment = issue
.get_comment(&client, fk_initiating_comment.try_into()?)
.await
.with_context(|| {
format!(
"failed to get first comment id={} for fcp={}",
fk_initiating_comment, fcp.fcp.id
)
})?;
(comment.html_url, quote_reply(&comment.body))
};

// TODO: agree with the team(s) a policy to emit actual mentions to remind FCP
// voting member to cast their vote
let should_mention = false;
Some(crate::actions::FCPDetails {
bot_tracking_comment_html_url,
bot_tracking_comment_content,
initiating_comment_html_url: init_comment.html_url.clone(),
initiating_comment_content: quote_reply(&init_comment.body),
initiating_comment_html_url,
initiating_comment_content,
disposition: fcp
.fcp
.disposition
Expand Down
6 changes: 3 additions & 3 deletions src/rfcbot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ pub struct FCP {
pub id: u32,
pub fk_issue: u32,
pub fk_initiator: u32,
pub fk_initiating_comment: u32,
pub fk_initiating_comment: i32,
pub disposition: Option<String>,
pub fk_bot_tracking_comment: u32,
pub fk_bot_tracking_comment: i32,
pub fcp_start: Option<String>,
pub fcp_closed: bool,
}
Expand Down Expand Up @@ -50,7 +50,7 @@ pub struct FCPIssue {

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct StatusComment {
pub id: u64,
pub id: i32,
pub fk_issue: u32,
pub fk_user: u32,
pub body: String,
Expand Down

0 comments on commit 0ddb063

Please sign in to comment.