mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
fix: Fix error handler token injection (#2598)
* fix: Fix error handler token injection * Add frontend
This commit is contained in:
committed by
GitHub
parent
198e282566
commit
aefa43dcaf
@@ -119,16 +119,6 @@ async fn create_schedule(
|
||||
));
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "enterprise"))]
|
||||
if ns.on_failure.is_some()
|
||||
&& ns.on_failure.as_ref().unwrap()
|
||||
== "script/hub/6512/workspace-or-schedule-error-handler-slack"
|
||||
{
|
||||
return Err(Error::BadRequest(
|
||||
"Slack error handler is only available in enterprise version".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "enterprise"))]
|
||||
if ns.on_failure_times.is_some() && ns.on_failure_times.unwrap() > 1 {
|
||||
return Err(Error::BadRequest(
|
||||
|
||||
@@ -812,14 +812,6 @@ async fn edit_error_handler(
|
||||
) -> Result<String> {
|
||||
require_admin(is_admin, &username)?;
|
||||
|
||||
#[cfg(not(feature = "enterprise"))]
|
||||
if ee.error_handler.as_ref().is_some_and(|val| val == "script/hub/2431/slack/schedule-error-handler-slack")
|
||||
{
|
||||
return Err(Error::BadRequest(
|
||||
"Slack error handler is only available in enterprise version".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let mut tx = db.begin().await?;
|
||||
|
||||
sqlx::query_as!(
|
||||
|
||||
@@ -596,9 +596,10 @@ pub async fn run_error_handler<
|
||||
}
|
||||
|
||||
// TODO: this should be injected when the EH is defined in the BE.
|
||||
if error_handler_path
|
||||
.to_string()
|
||||
.eq("hub/6512/workspace-or-schedule-error-handler-slack")
|
||||
if error_handler_path.to_string().starts_with("hub/")
|
||||
&& error_handler_path
|
||||
.to_string()
|
||||
.ends_with("/workspace-or-schedule-error-handler-slack")
|
||||
{
|
||||
// default slack error handler being used -> we need to inject the slack token
|
||||
let slack_resource = format!("$res:{WORKSPACE_SLACK_BOT_TOKEN_PATH}");
|
||||
@@ -1036,9 +1037,10 @@ pub async fn handle_on_failure<
|
||||
}
|
||||
|
||||
// TODO: This should be inject when the EH is defined in the FE.
|
||||
if on_failure_path
|
||||
.to_string()
|
||||
.eq("script/hub/6512/workspace-or-schedule-error-handler-slack")
|
||||
if on_failure_path.to_string().starts_with("script/hub/")
|
||||
&& on_failure_path
|
||||
.to_string()
|
||||
.ends_with("/workspace-or-schedule-error-handler-slack")
|
||||
{
|
||||
// default slack error handler being used -> we need to inject the slack token
|
||||
let slack_resource = format!("$res:{WORKSPACE_SLACK_BOT_TOKEN_PATH}");
|
||||
|
||||
@@ -218,7 +218,8 @@
|
||||
<span class="w-full flex mb-3">
|
||||
<Toggle
|
||||
disabled={!$enterpriseLicense || !isEditable}
|
||||
checked={handlerPath === slackHandlerScriptPath}
|
||||
checked={handlerPath?.startsWith('hub/') &&
|
||||
handlerPath?.endsWith('/workspace-or-schedule-error-handler-slack')}
|
||||
options={{ right: slackToggleText }}
|
||||
on:change={async (e) => {
|
||||
handlerPath = e.detail ? slackHandlerScriptPath : undefined
|
||||
@@ -238,7 +239,7 @@
|
||||
class="text-xs"
|
||||
/>
|
||||
{/if}
|
||||
{#if handlerPath === slackHandlerScriptPath && enterpriseLicense}
|
||||
{#if enterpriseLicense && handlerPath?.startsWith('hub/') && handlerPath?.endsWith('/workspace-or-schedule-error-handler-slack')}
|
||||
{#if !workspaceConnectedToSlack}
|
||||
<Alert type="error" title="Workspace not connected to Slack">
|
||||
<div class="flex flex-row gap-x-1 w-full items-center">
|
||||
|
||||
@@ -92,7 +92,10 @@
|
||||
errorHandlerPath = splitted.slice(1)?.join('/')
|
||||
errorHandlerExtraArgs = defaultErrorHandlerMaybe['errorHandlerExtraArgs']
|
||||
errorHandlerCustomInitialPath = errorHandlerPath
|
||||
if (errorHandlerPath === slackErrorHandler) {
|
||||
if (
|
||||
errorHandlerPath.startsWith('hub/') &&
|
||||
errorHandlerPath.endsWith('/workspace-or-schedule-error-handler-slack')
|
||||
) {
|
||||
errorHandlerSelected = 'slack'
|
||||
} else {
|
||||
errorHandlerSelected = 'custom'
|
||||
@@ -229,7 +232,12 @@
|
||||
failedTimes = s.on_failure_times ?? 1
|
||||
failedExact = s.on_failure_exact ?? false
|
||||
errorHandlerExtraArgs = s.on_failure_extra_args ?? {}
|
||||
if (errorHandlerPath !== slackErrorHandler) {
|
||||
if (
|
||||
errorHandlerPath.startsWith('hub/') &&
|
||||
errorHandlerPath.endsWith('/workspace-or-schedule-error-handler-slack')
|
||||
) {
|
||||
errorHandlerSelected = 'slack'
|
||||
} else {
|
||||
errorHandlerSelected = 'custom'
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -172,7 +172,9 @@
|
||||
errorHandlerSelected = 'custom'
|
||||
} else {
|
||||
errorHandlerSelected =
|
||||
emptyString(errorHandlerScriptPath) || errorHandlerScriptPath === slackErrorHandler
|
||||
emptyString(errorHandlerScriptPath) ||
|
||||
(errorHandlerScriptPath.startsWith('hub/') &&
|
||||
errorHandlerScriptPath.endsWith('/workspace-or-schedule-error-handler-slack'))
|
||||
? 'slack'
|
||||
: 'custom'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user