From 18b737241b2671979ff04d5143e21d29deaed3cb Mon Sep 17 00:00:00 2001 From: Alexander Petric Date: Wed, 18 Dec 2024 10:20:25 +0100 Subject: [PATCH] ellipsis comments --- backend/windmill-api/src/slack_approvals.rs | 16 ++++++++++++++-- typescript-client/client.ts | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/windmill-api/src/slack_approvals.rs b/backend/windmill-api/src/slack_approvals.rs index 281c7e75a545a..9cdf38ebf4ff2 100644 --- a/backend/windmill-api/src/slack_approvals.rs +++ b/backend/windmill-api/src/slack_approvals.rs @@ -99,6 +99,10 @@ pub async fn slack_app_callback_handler( tracing::debug!("Form data: {:#?}", form_data); let payload: Payload = serde_json::from_str(&form_data.payload)?; + if payload.actions.is_empty() { + return Err(Error::BadRequest("No actions found in payload.".to_string())); + } + let action_value = payload.actions[0].value.clone(); let response_url = payload.response_url.clone(); @@ -126,13 +130,21 @@ pub async fn slack_app_callback_handler( tracing::debug!("W ID: {}, Action: {}, Job ID: {}, Resume ID: {}, Secret: {}, Approver: {:?}, State JSON: {:?}", w_id, action, job_id, resume_id, secret, approver.approver, state_json); + let job_uuid = Uuid::from_str(job_id).map_err(|_| { + Error::BadRequest("Invalid job ID format.".to_string()) + })?; + + let resume_id_parsed = resume_id.parse::().map_err(|_| { + Error::BadRequest("Invalid resume ID format.".to_string()) + })?; + let res = resume_suspended_job( authed, Extension(db), Path(( w_id.to_string(), - Uuid::from_str(job_id).unwrap_or_default(), - resume_id.parse::().unwrap_or_default(), + job_uuid, + resume_id_parsed, secret.to_string(), )), Query(approver), diff --git a/typescript-client/client.ts b/typescript-client/client.ts index 212ea8175a29c..d52bfb3aee1b8 100644 --- a/typescript-client/client.ts +++ b/typescript-client/client.ts @@ -869,7 +869,7 @@ export async function requestInteractiveSlackApproval({ if (!flowJobId) { throw new Error( - "You can't use this function in a standalon script or flow step preview. Please us it in a flow or a flow preview." + "You can't use this function in a standalone script or flow step preview. Please us it in a flow or a flow preview." ); }