Skip to content
1 change: 1 addition & 0 deletions services/gateway/src/routes/alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,7 @@ async fn start_run(
false,
false,
None,
false,
)
.await
{
Expand Down
27 changes: 10 additions & 17 deletions services/gateway/src/routes/github_webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,22 +519,11 @@ async fn handle_issue_event(
installation_id: u64,
team_id: &str,
) -> Result<StatusCode, StatusCode> {
let action = payload["action"].as_str().unwrap_or("");

// Trigger on: issue assigned to coderhelm[bot], or labeled "coderhelm"
let is_assigned_to_bot = action == "assigned"
&& payload["assignee"]["login"]
.as_str()
.map(|l| l.contains("coderhelm"))
.unwrap_or(false);

let is_labeled = action == "labeled"
&& payload["label"]["name"]
.as_str()
.map(|l| l.eq_ignore_ascii_case("coderhelm"))
.unwrap_or(false);

if !is_assigned_to_bot && !is_labeled {
// Trigger on: issue assigned to coderhelm[bot], or labeled "coderhelm".
// One rule for the trigger and for the failed-run cap, which never
// blocks a person's retry gesture.
let retry_gesture = super::trigger_gate::github_retry_gesture(payload);
if !retry_gesture {
return Ok(StatusCode::OK);
}
let issue = &payload["issue"];
Expand Down Expand Up @@ -575,7 +564,9 @@ async fn handle_issue_event(
// run, re-trigger only if the issue content changed (re-labeling an
// edited issue reworks it; re-labeling an unchanged one is a no-op).
// Failed/needs_input runs no longer block — the old any-run-exists check
// made GitHub tickets unretriable by re-label.
// made GitHub tickets unretriable by re-label. Every issue event that
// gets here is a person's retry gesture (the label added, or CoderHelm
// assigned), so it retries a failed issue even past the failed-run cap.
let ticket_id_str = format!("GH-{}", issue["number"].as_u64().unwrap_or(0));
let context_hash = common::ticket_context_hash(
issue["title"].as_str().unwrap_or(""),
Expand All @@ -595,6 +586,7 @@ async fn handle_issue_event(
false,
false,
Some(&own_repo),
retry_gesture,
)
.await
{
Expand Down Expand Up @@ -1675,6 +1667,7 @@ async fn handle_issue_comment(
true,
false,
Some(&own_repo),
false,
)
.await,
super::trigger_gate::TicketGate::SkipInFlight
Expand Down
8 changes: 4 additions & 4 deletions services/gateway/src/routes/jira_webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,9 @@ fn assignee_of(issue: &Value) -> &str {
/// CoderHelm). Either one starts a run, and either one is what lets a
/// comment written before the run be kept for it.
pub(crate) fn ticket_triggers(issue: &Value, trigger_label: &str) -> (bool, bool) {
let label = trigger_label.to_ascii_lowercase();
let has_label = labels_of(issue).iter().any(|l| {
l.eq_ignore_ascii_case(&label) || l.to_ascii_lowercase().starts_with(&format!("{label}:"))
});
let has_label = labels_of(issue)
.iter()
.any(|l| super::trigger_gate::is_trigger_label(l, trigger_label));
let is_assigned = assignee_of(issue)
.to_ascii_lowercase()
.contains("coderhelm");
Expand Down Expand Up @@ -616,6 +615,7 @@ async fn process_jira_payload(
false,
super::trigger_gate::jira_reopened(payload),
None,
super::trigger_gate::jira_retry_gesture(payload, &trigger_label),
)
.await
{
Expand Down
15 changes: 12 additions & 3 deletions services/gateway/src/routes/run_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ async fn github_ticket(
true,
false,
Some(repo),
false,
)
.await;
if let Some(refused) = gate_refusal(&gate) {
Expand Down Expand Up @@ -267,9 +268,17 @@ async fn jira_ticket(
.map_err(|e| internal("Run not read", e))?
.item
.ok_or_else(|| fail(StatusCode::NOT_FOUND, "That ticket's last run is gone."))?;
let gate =
trigger_gate::gate_ticket_trigger(state, &claims.team_id, key, None, true, false, None)
.await;
let gate = trigger_gate::gate_ticket_trigger(
state,
&claims.team_id,
key,
None,
true,
false,
None,
false,
)
.await;
if let Some(refused) = gate_refusal(&gate) {
return Err(refused);
}
Expand Down
Loading
Loading