From 45641cbbab7d3f2fb6b75f27357ec84d96f269d7 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 1 Jun 2023 17:15:37 +0200 Subject: [PATCH] make to_i64 more resilient and clearer error message on client setup --- backend/windmill-api/src/oauth2.rs | 4 ++-- backend/windmill-common/src/scripts.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/windmill-api/src/oauth2.rs b/backend/windmill-api/src/oauth2.rs index f73b70f7e9..c30488c5d8 100644 --- a/backend/windmill-api/src/oauth2.rs +++ b/backend/windmill-api/src/oauth2.rs @@ -415,7 +415,7 @@ async fn connect_slack(cookies: Cookies) -> error::Result { let mut client = OAUTH_CLIENTS .slack .as_ref() - .ok_or_else(|| error::Error::BadRequest("slack client not setup".to_string()))? + .ok_or_else(|| error::Error::BadRequest("slack client not setup. See: https://docs.windmill.dev/docs/misc/setup_oauth#slack".to_string()))? .to_owned(); let state = State::new_random(); @@ -616,7 +616,7 @@ async fn connect_slack_callback( let client = OAUTH_CLIENTS .slack .as_ref() - .ok_or_else(|| error::Error::BadRequest("slack client not setup".to_string()))? + .ok_or_else(|| error::Error::BadRequest("slack client not setup. See: https://docs.windmill.dev/docs/misc/setup_oauth#slack".to_string()))? .to_owned(); let token = exchange_code::(callback, &cookies, client, &HTTP_CLIENT, None).await?; diff --git a/backend/windmill-common/src/scripts.rs b/backend/windmill-common/src/scripts.rs index b3a29f85e4..4edab16bf8 100644 --- a/backend/windmill-common/src/scripts.rs +++ b/backend/windmill-common/src/scripts.rs @@ -209,6 +209,11 @@ pub struct ListScriptQuery { pub fn to_i64(s: &str) -> crate::error::Result { let v = hex::decode(s)?; + if v.len() < 8 { + return Err(crate::error::Error::BadRequest(format!( + "hex string did not decode to an u64: {s}", + ))); + } let nb: u64 = u64::from_be_bytes( v[0..8] .try_into()