diff --git a/backend/tests/app_preview_auth.rs b/backend/tests/app_preview_auth.rs index 9f6e77f61c..197ab16f8e 100644 --- a/backend/tests/app_preview_auth.rs +++ b/backend/tests/app_preview_auth.rs @@ -388,3 +388,49 @@ async fn test_app_preview_authorization(db: Pool) -> anyhow::Result<() Ok(()) } + +#[sqlx::test(fixtures("base"))] +async fn test_path_with_id_is_refused(db: Pool) -> anyhow::Result<()> { + initialize_tracing().await; + let server = ApiServer::start(db.clone()).await?; + let ws = format!( + "http://localhost:{}/api/w/test-workspace", + server.addr.port() + ); + + let app_path = "u/test-user/path_with_id"; + let resp = authed(client().post(format!("{ws}/apps/create")), "SECRET_TOKEN") + .json(&json!({ + "path": app_path, + "summary": "", + "value": {}, + "policy": { + "execution_mode": "viewer", + "triggerables_v2": { + "comp:script/u/test-user/ok": { "static_inputs": {}, "one_of_inputs": {} } + } + } + })) + .send() + .await?; + assert_eq!(resp.status(), 201, "create app: {}", resp.text().await?); + + let resp = authed( + client().post(format!("{ws}/apps_u/execute_component/{app_path}")), + "SECRET_TOKEN", + ) + .json(&json!({ + "args": {}, + "component": "comp", + "path": "script/u/test-user/ok", + "id": 1 + })) + .send() + .await?; + let status = resp.status(); + let body = resp.text().await?; + assert_eq!(status, 400, "path with id must be refused: {body}"); + assert!(body.contains("path and id cannot be set"), "got: {body}"); + + Ok(()) +} diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index bfe317c1b7..1c6c386ab5 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -16240,6 +16240,7 @@ paths: #flow: flow/ path: type: string + description: Runnable to run. Cannot be sent with `raw_code` or `id`. version: type: integer args: {} @@ -16269,6 +16270,7 @@ paths: - language id: type: integer + description: ID of a deployed inline script, sent with `raw_code`. Cannot be sent with `path`. force_viewer_static_fields: type: object force_viewer_one_of_fields: diff --git a/backend/windmill-api/src/apps.rs b/backend/windmill-api/src/apps.rs index d55bdb8ea6..60a0a168d3 100644 --- a/backend/windmill-api/src/apps.rs +++ b/backend/windmill-api/src/apps.rs @@ -4577,6 +4577,11 @@ async fn execute_component( "path and raw_code cannot be set at the same time".to_string(), )) } + (true, false) if payload.id.is_some() => { + return Err(Error::BadRequest( + "path and id cannot be set at the same time".to_string(), + )) + } _ => {} };