make to_i64 more resilient and clearer error message on client setup

This commit is contained in:
Ruben Fiszel
2023-06-01 17:15:37 +02:00
parent 7329d59e96
commit 45641cbbab
2 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -415,7 +415,7 @@ async fn connect_slack(cookies: Cookies) -> error::Result<Redirect> {
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::<SlackTokenResponse>(callback, &cookies, client, &HTTP_CLIENT, None).await?;
+5
View File
@@ -209,6 +209,11 @@ pub struct ListScriptQuery {
pub fn to_i64(s: &str) -> crate::error::Result<i64> {
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()