From 3a5b670fcaeb86a98650ebf965ca4b5bfa26a8cf Mon Sep 17 00:00:00 2001 From: Tsvetomir Bonev Date: Thu, 9 Jan 2025 19:21:59 +0200 Subject: [PATCH 1/2] chore: update rust to `1.81.0` (#5037) --- docker/DockerfileFull | 4 ++-- docker/DockerfileFullEe | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/DockerfileFull b/docker/DockerfileFull index a79455eb75cc2..6f86b0a21e51c 100644 --- a/docker/DockerfileFull +++ b/docker/DockerfileFull @@ -1,7 +1,7 @@ FROM ghcr.io/windmill-labs/windmill:dev -COPY --from=rust:1.80.1 /usr/local/cargo /usr/local/cargo -COPY --from=rust:1.80.1 /usr/local/rustup /usr/local/rustup +COPY --from=rust:1.81.0 /usr/local/cargo /usr/local/cargo +COPY --from=rust:1.81.0 /usr/local/rustup /usr/local/rustup RUN pip3 install ansible diff --git a/docker/DockerfileFullEe b/docker/DockerfileFullEe index a932a6222e08b..5f7870cc828f7 100644 --- a/docker/DockerfileFullEe +++ b/docker/DockerfileFullEe @@ -1,7 +1,7 @@ FROM ghcr.io/windmill-labs/windmill-ee:dev -COPY --from=rust:1.80.1 /usr/local/cargo /usr/local/cargo -COPY --from=rust:1.80.1 /usr/local/rustup /usr/local/rustup +COPY --from=rust:1.81.0 /usr/local/cargo /usr/local/cargo +COPY --from=rust:1.81.0 /usr/local/rustup /usr/local/rustup RUN pip3 install ansible From 7b808c39771efb7c6b440b2a15427b4b1a7700ab Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Thu, 9 Jan 2025 19:08:56 +0100 Subject: [PATCH 2/2] fix(backend): multiple routes with same path but different methods (#5040) --- ...b357c6147e186e00e371f7374d166903ef64.json} | 24 ++++++------- ...3d393ed0bb73314e5c430f32541c43bcac52.json} | 25 ++++++------- backend/windmill-api/src/http_triggers.rs | 35 ++++++++++--------- 3 files changed, 38 insertions(+), 46 deletions(-) rename backend/.sqlx/{query-11b698f82a54aac68b3617047dfe2b18dd6da7d962118fee276af354218baac2.json => query-28a389a93a3d2472b13d956ec55eb357c6147e186e00e371f7374d166903ef64.json} (81%) rename backend/.sqlx/{query-c9930fcfe79541af570eace58ba7e15a0816a6b4fd036cf7b991a210654b2633.json => query-a76be7f4e9e8b8c81afe50fcbf1f3d393ed0bb73314e5c430f32541c43bcac52.json} (80%) diff --git a/backend/.sqlx/query-11b698f82a54aac68b3617047dfe2b18dd6da7d962118fee276af354218baac2.json b/backend/.sqlx/query-28a389a93a3d2472b13d956ec55eb357c6147e186e00e371f7374d166903ef64.json similarity index 81% rename from backend/.sqlx/query-11b698f82a54aac68b3617047dfe2b18dd6da7d962118fee276af354218baac2.json rename to backend/.sqlx/query-28a389a93a3d2472b13d956ec55eb357c6147e186e00e371f7374d166903ef64.json index 99004617618ab..a8a68c9237bc7 100644 --- a/backend/.sqlx/query-11b698f82a54aac68b3617047dfe2b18dd6da7d962118fee276af354218baac2.json +++ b/backend/.sqlx/query-28a389a93a3d2472b13d956ec55eb357c6147e186e00e371f7374d166903ef64.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, http_method as \"http_method: _\", static_asset_config as \"static_asset_config: _\" FROM http_trigger", + "query": "SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, static_asset_config as \"static_asset_config: _\" FROM http_trigger WHERE http_method = $1", "describe": { "columns": [ { @@ -50,8 +50,13 @@ }, { "ordinal": 9, - "name": "http_method: _", - "type_info": { + "name": "static_asset_config: _", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + { "Custom": { "name": "http_method", "kind": { @@ -65,15 +70,7 @@ } } } - }, - { - "ordinal": 10, - "name": "static_asset_config: _", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [] + ] }, "nullable": [ false, @@ -85,9 +82,8 @@ false, false, false, - false, true ] }, - "hash": "11b698f82a54aac68b3617047dfe2b18dd6da7d962118fee276af354218baac2" + "hash": "28a389a93a3d2472b13d956ec55eb357c6147e186e00e371f7374d166903ef64" } diff --git a/backend/.sqlx/query-c9930fcfe79541af570eace58ba7e15a0816a6b4fd036cf7b991a210654b2633.json b/backend/.sqlx/query-a76be7f4e9e8b8c81afe50fcbf1f3d393ed0bb73314e5c430f32541c43bcac52.json similarity index 80% rename from backend/.sqlx/query-c9930fcfe79541af570eace58ba7e15a0816a6b4fd036cf7b991a210654b2633.json rename to backend/.sqlx/query-a76be7f4e9e8b8c81afe50fcbf1f3d393ed0bb73314e5c430f32541c43bcac52.json index da7b44d1b95c7..fb1cea135adae 100644 --- a/backend/.sqlx/query-c9930fcfe79541af570eace58ba7e15a0816a6b4fd036cf7b991a210654b2633.json +++ b/backend/.sqlx/query-a76be7f4e9e8b8c81afe50fcbf1f3d393ed0bb73314e5c430f32541c43bcac52.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, http_method as \"http_method: _\", static_asset_config as \"static_asset_config: _\" FROM http_trigger WHERE workspace_id = $1", + "query": "SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, static_asset_config as \"static_asset_config: _\" FROM http_trigger WHERE workspace_id = $1 AND http_method = $2", "describe": { "columns": [ { @@ -50,8 +50,14 @@ }, { "ordinal": 9, - "name": "http_method: _", - "type_info": { + "name": "static_asset_config: _", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Text", + { "Custom": { "name": "http_method", "kind": { @@ -65,16 +71,6 @@ } } } - }, - { - "ordinal": 10, - "name": "static_asset_config: _", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Text" ] }, "nullable": [ @@ -87,9 +83,8 @@ false, false, false, - false, true ] }, - "hash": "c9930fcfe79541af570eace58ba7e15a0816a6b4fd036cf7b991a210654b2633" + "hash": "a76be7f4e9e8b8c81afe50fcbf1f3d393ed0bb73314e5c430f32541c43bcac52" } diff --git a/backend/windmill-api/src/http_triggers.rs b/backend/windmill-api/src/http_triggers.rs index 85bbf64abda07..00a2cd915cc49 100644 --- a/backend/windmill-api/src/http_triggers.rs +++ b/backend/windmill-api/src/http_triggers.rs @@ -85,14 +85,16 @@ pub enum HttpMethod { Patch, } -impl From for http::Method { - fn from(method: HttpMethod) -> Self { +impl TryFrom<&http::Method> for HttpMethod { + type Error = error::Error; + fn try_from(method: &http::Method) -> Result { match method { - HttpMethod::Get => http::Method::GET, - HttpMethod::Post => http::Method::POST, - HttpMethod::Put => http::Method::PUT, - HttpMethod::Delete => http::Method::DELETE, - HttpMethod::Patch => http::Method::PATCH, + &http::Method::GET => Ok(HttpMethod::Get), + &http::Method::POST => Ok(HttpMethod::Post), + &http::Method::PUT => Ok(HttpMethod::Put), + &http::Method::DELETE => Ok(HttpMethod::Delete), + &http::Method::PATCH => Ok(HttpMethod::Patch), + _ => Err(error::Error::BadRequest("Invalid HTTP method".to_string())), } } } @@ -417,7 +419,6 @@ struct TriggerRoute { requires_auth: bool, edited_by: String, email: String, - http_method: HttpMethod, static_asset_config: Option>, } @@ -427,7 +428,9 @@ async fn get_http_route_trigger( token: Option<&String>, db: &DB, user_db: UserDB, + method: &http::Method, ) -> error::Result<(TriggerRoute, String, HashMap, ApiAuthed)> { + let http_method: HttpMethod = method.try_into()?; let (mut triggers, route_path) = if *CLOUD_HOSTED { let mut splitted = route_path.split("/"); let w_id = splitted.next().ok_or_else(|| { @@ -436,8 +439,9 @@ async fn get_http_route_trigger( let route_path = StripPath(splitted.collect::>().join("/")); let triggers = sqlx::query_as!( TriggerRoute, - r#"SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, http_method as "http_method: _", static_asset_config as "static_asset_config: _" FROM http_trigger WHERE workspace_id = $1"#, - w_id + r#"SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, static_asset_config as "static_asset_config: _" FROM http_trigger WHERE workspace_id = $1 AND http_method = $2"#, + w_id, + http_method as HttpMethod ) .fetch_all(db) .await?; @@ -445,7 +449,8 @@ async fn get_http_route_trigger( } else { let triggers = sqlx::query_as!( TriggerRoute, - r#"SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, http_method as "http_method: _", static_asset_config as "static_asset_config: _" FROM http_trigger"#, + r#"SELECT path, script_path, is_flow, route_path, workspace_id, is_async, requires_auth, edited_by, email, static_asset_config as "static_asset_config: _" FROM http_trigger WHERE http_method = $1"#, + http_method as HttpMethod ) .fetch_all(db) .await?; @@ -567,6 +572,7 @@ async fn route_job( token.as_ref(), &db, user_db.clone(), + &method, ) .await { @@ -678,15 +684,10 @@ async fn route_job( ) .await, ); - let http_method = http::Method::from(trigger.http_method); - - if http_method != method { - return error::Error::BadRequest("Invalid HTTP method".to_string()).into_response(); - } let label_prefix = Some(format!( "http-{}-{}-", - http_method.as_str().to_lowercase(), + method.as_str().to_lowercase(), trigger.route_path ));